Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
4950bb91
Commit
4950bb91
authored
Jun 30, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing tests after latest refactoring
parent
99d9fbff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
35 deletions
+29
-35
spec/chatbox.js
spec/chatbox.js
+11
-11
spec/chatroom.js
spec/chatroom.js
+3
-3
spec/controlbox.js
spec/controlbox.js
+11
-17
spec/minchats.js
spec/minchats.js
+2
-2
tests/utils.js
tests/utils.js
+2
-2
No files found.
spec/chatbox.js
View file @
4950bb91
...
...
@@ -13,7 +13,7 @@
runs
(
function
()
{
utils
.
closeAllChatBoxes
();
utils
.
removeControlBox
();
converse
.
roster
.
local
Storage
.
_clear
();
converse
.
roster
.
browser
Storage
.
_clear
();
utils
.
initConverse
();
utils
.
createCurrentContacts
();
utils
.
openControlBox
();
...
...
@@ -115,7 +115,7 @@
expect
(
chatboxview
.
focus
).
toHaveBeenCalled
();
},
converse
));
it
(
"
can be saved to, and retrieved from,
local
Storage
"
,
$
.
proxy
(
function
()
{
it
(
"
can be saved to, and retrieved from,
browser
Storage
"
,
$
.
proxy
(
function
()
{
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
chatboxviews
,
'
trimChats
'
);
runs
(
function
()
{
...
...
@@ -129,11 +129,11 @@
// will be empty.
var
newchatboxes
=
new
this
.
ChatBoxes
();
expect
(
newchatboxes
.
length
).
toEqual
(
0
);
// The chatboxes will then be fetched from
local
Storage inside the
// The chatboxes will then be fetched from
browser
Storage inside the
// onConnected method
newchatboxes
.
onConnected
();
expect
(
newchatboxes
.
length
).
toEqual
(
7
);
// Check that the chatboxes items retrieved from
local
Storage
// Check that the chatboxes items retrieved from
browser
Storage
// have the same attributes values as the original ones.
attrs
=
[
'
id
'
,
'
box_id
'
,
'
visible
'
];
for
(
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
...
...
@@ -212,10 +212,10 @@
});
}.
bind
(
converse
));
it
(
"
will be removed from
local
Storage when closed
"
,
$
.
proxy
(
function
()
{
it
(
"
will be removed from
browser
Storage when closed
"
,
$
.
proxy
(
function
()
{
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
.
chatboxviews
,
'
trimChats
'
);
this
.
chatboxes
.
local
Storage
.
_clear
();
this
.
chatboxes
.
browser
Storage
.
_clear
();
runs
(
function
()
{
utils
.
closeControlBox
();
});
...
...
@@ -235,9 +235,9 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onChatBoxClosed
'
,
jasmine
.
any
(
Object
));
var
newchatboxes
=
new
this
.
ChatBoxes
();
expect
(
newchatboxes
.
length
).
toEqual
(
0
);
// onConnected will fetch chatboxes in
local
Storage, but
// onConnected will fetch chatboxes in
browser
Storage, but
// because there aren't any open chatboxes, there won't be any
// in
local
Storage either. XXX except for the controlbox
// in
browser
Storage either. XXX except for the controlbox
newchatboxes
.
onConnected
();
expect
(
newchatboxes
.
length
).
toEqual
(
1
);
expect
(
newchatboxes
.
models
[
0
].
id
).
toBe
(
"
controlbox
"
);
...
...
@@ -692,7 +692,7 @@
beforeEach
(
function
()
{
utils
.
closeAllChatBoxes
();
utils
.
removeControlBox
();
converse
.
roster
.
local
Storage
.
_clear
();
converse
.
roster
.
browser
Storage
.
_clear
();
utils
.
initConverse
();
utils
.
createCurrentContacts
();
utils
.
openControlBox
();
...
...
@@ -709,7 +709,7 @@
// (e.g for when this test is run on its own).
utils
.
sendMessage
(
view
,
message
);
expect
(
view
.
model
.
messages
.
length
>
0
).
toBeTruthy
();
expect
(
view
.
model
.
messages
.
local
Storage
.
records
.
length
>
0
).
toBeTruthy
();
expect
(
view
.
model
.
messages
.
browser
Storage
.
records
.
length
>
0
).
toBeTruthy
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onMessageSend
'
,
message
);
message
=
'
/clear
'
;
...
...
@@ -724,7 +724,7 @@
expect
(
view
.
clearMessages
).
toHaveBeenCalled
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
view
.
model
.
messages
.
length
,
0
);
// The messages must be removed from the chatbox
expect
(
view
.
model
.
messages
.
localStorage
.
records
.
length
,
0
);
// And also from local
Storage
expect
(
view
.
model
.
messages
.
browserStorage
.
records
.
length
,
0
);
// And also from browser
Storage
expect
(
converse
.
emit
.
callCount
,
1
);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
onMessageSend
'
,
message
]);
},
converse
));
...
...
spec/chatroom.js
View file @
4950bb91
...
...
@@ -112,19 +112,19 @@
expect
(
converse
.
emit
.
callCount
,
1
);
},
converse
));
it
(
"
can be saved to, and retrieved from,
local
Storage
"
,
$
.
proxy
(
function
()
{
it
(
"
can be saved to, and retrieved from,
browser
Storage
"
,
$
.
proxy
(
function
()
{
// We instantiate a new ChatBoxes collection, which by default
// will be empty.
spyOn
(
this
.
chatboxviews
,
'
trimChats
'
);
utils
.
openControlBox
();
var
newchatboxes
=
new
this
.
ChatBoxes
();
expect
(
newchatboxes
.
length
).
toEqual
(
0
);
// The chatboxes will then be fetched from
local
Storage inside the
// The chatboxes will then be fetched from
browser
Storage inside the
// onConnected method
newchatboxes
.
onConnected
();
expect
(
this
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
expect
(
newchatboxes
.
length
).
toEqual
(
2
);
// XXX: Includes controlbox, is this a bug?
// Check that the chatrooms retrieved from
local
Storage
// Check that the chatrooms retrieved from
browser
Storage
// have the same attributes values as the original ones.
attrs
=
[
'
id
'
,
'
box_id
'
,
'
visible
'
];
for
(
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
...
...
spec/controlbox.js
View file @
4950bb91
...
...
@@ -42,11 +42,7 @@
describe
(
"
The Status Widget
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
utils
.
openControlBox
();
});
waits
(
250
);
runs
(
function
()
{});
utils
.
openControlBox
();
});
it
(
"
shows the user's chat status, which is online by default
"
,
$
.
proxy
(
function
()
{
...
...
@@ -118,11 +114,11 @@
runs
(
function
()
{
utils
.
openControlBox
();
});
waits
(
2
50
);
waits
(
50
);
runs
(
function
()
{
utils
.
openContactsPanel
();
});
waits
(
2
50
);
waits
(
50
);
runs
(
function
()
{});
});
...
...
@@ -210,12 +206,10 @@
runs
(
function
()
{
utils
.
openControlBox
();
});
waits
(
2
50
);
waits
(
50
);
runs
(
function
()
{
utils
.
openContactsPanel
();
});
waits
(
250
);
runs
(
function
()
{});
},
converse
));
it
(
"
do not have a heading if there aren't any
"
,
$
.
proxy
(
function
()
{
...
...
@@ -436,19 +430,19 @@
},
converse
));
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
it
(
"
are saved to, and can be retrieved from,
local
Storage
"
,
$
.
proxy
(
function
()
{
it
(
"
are saved to, and can be retrieved from,
browser
Storage
"
,
$
.
proxy
(
function
()
{
var
new_attrs
,
old_attrs
,
attrs
,
old_roster
;
var
num_contacts
=
this
.
roster
.
length
;
new_roster
=
new
this
.
RosterItems
();
// Roster items are yet to be fetched from
local
Storage
// Roster items are yet to be fetched from
browser
Storage
expect
(
new_roster
.
length
).
toEqual
(
0
);
new_roster
.
localStorage
=
new
Backbone
.
LocalStorage
(
new_roster
.
browserStorage
=
new
Backbone
.
BrowserStorage
.
session
(
b64_sha1
(
'
converse.rosteritems-dummy@localhost
'
));
new_roster
.
fetch
();
expect
(
this
.
roster
.
length
).
toEqual
(
num_contacts
);
// Check that the roster items retrieved from
local
Storage
expect
(
new_
roster
.
length
).
toEqual
(
num_contacts
);
// Check that the roster items retrieved from
browser
Storage
// have the same attributes values as the original ones.
attrs
=
[
'
jid
'
,
'
fullname
'
,
'
subscription
'
,
'
ask
'
];
for
(
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
...
...
@@ -463,7 +457,7 @@
},
converse
));
afterEach
(
$
.
proxy
(
function
()
{
// Contacts retrieved from
local
Storage have chat_status of
// Contacts retrieved from
browser
Storage have chat_status of
// "offline".
// In the next test suite, we need some online contacts, so
// we make some online now
...
...
@@ -515,7 +509,7 @@
runs
(
function
()
{
utils
.
closeAllChatBoxes
();
});
waits
(
2
50
);
waits
(
50
);
runs
(
function
()
{
utils
.
openControlBox
();
});
...
...
spec/minchats.js
View file @
4950bb91
...
...
@@ -13,12 +13,12 @@
runs
(
function
()
{
utils
.
closeAllChatBoxes
();
utils
.
removeControlBox
();
converse
.
roster
.
local
Storage
.
_clear
();
converse
.
roster
.
browser
Storage
.
_clear
();
utils
.
initConverse
();
utils
.
createCurrentContacts
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
converse
.
minimized_chats
.
toggleview
.
model
.
local
Storage
.
_clear
();
converse
.
minimized_chats
.
toggleview
.
model
.
browser
Storage
.
_clear
();
converse
.
minimized_chats
.
initToggle
();
});
});
...
...
tests/utils.js
View file @
4950bb91
...
...
@@ -36,7 +36,7 @@
};
utils
.
initRoster
=
function
()
{
converse
.
roster
.
local
Storage
.
_clear
();
converse
.
roster
.
browser
Storage
.
_clear
();
converse
.
initRoster
();
};
...
...
@@ -93,7 +93,7 @@
var
view
=
converse
.
chatboxviews
.
get
(
jid
);
view
.
$el
.
find
(
'
.chat-content
'
).
empty
();
view
.
model
.
messages
.
reset
();
view
.
model
.
messages
.
local
Storage
.
_clear
();
view
.
model
.
messages
.
browser
Storage
.
_clear
();
};
utils
.
createCurrentContacts
=
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment