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
df91f178
Commit
df91f178
authored
Jul 14, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests. Emitted events weren't yet renamed in the tests.
parent
9846f89a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
53 deletions
+53
-53
spec/chatbox.js
spec/chatbox.js
+18
-18
spec/chatroom.js
spec/chatroom.js
+5
-5
spec/controlbox.js
spec/controlbox.js
+14
-14
spec/eventemitter.js
spec/eventemitter.js
+16
-16
No files found.
spec/chatbox.js
View file @
df91f178
...
...
@@ -162,14 +162,14 @@
waits
(
250
);
runs
(
function
()
{
expect
(
controlview
.
close
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
.
callCount
,
1
);
chatview
.
$el
.
find
(
'
.close-chatbox-button
'
).
click
();
});
waits
(
250
);
runs
(
function
()
{
expect
(
chatview
.
close
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
.
callCount
,
2
);
});
},
converse
));
...
...
@@ -190,7 +190,7 @@
waits
(
250
);
runs
(
function
()
{
expect
(
chatview
.
minimize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
.
callCount
,
2
);
expect
(
chatview
.
$el
.
is
(
'
:visible
'
)).
toBeFalsy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
...
...
@@ -203,7 +203,7 @@
waits
(
250
);
runs
(
function
()
{
expect
(
trimmedview
.
restore
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
chatview
.
$el
.
find
(
'
.chat-body
'
).
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatview
.
$el
.
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
icon-minus
'
)).
toBeTruthy
();
expect
(
chatview
.
$el
.
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
icon-plus
'
)).
toBeFalsy
();
...
...
@@ -220,18 +220,18 @@
});
waits
(
250
);
runs
(
function
()
{
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
chatboxes
.
length
).
toEqual
(
0
);
utils
.
openChatBoxes
(
6
);
expect
(
converse
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
expect
(
converse
.
chatboxes
.
length
).
toEqual
(
6
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxOpened
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxOpened
'
,
jasmine
.
any
(
Object
));
utils
.
closeAllChatBoxes
();
});
waits
(
250
);
runs
(
function
()
{
expect
(
converse
.
chatboxes
.
length
).
toEqual
(
0
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
var
newchatboxes
=
new
this
.
ChatBoxes
();
expect
(
newchatboxes
.
length
).
toEqual
(
0
);
// onConnected will fetch chatboxes in browserStorage, but
...
...
@@ -352,7 +352,7 @@
expect
(
callButton
.
length
).
toBe
(
0
);
view
.
close
();
// Now check that it's shown if enabled and that it emits
//
onC
allButtonClicked
//
c
allButtonClicked
converse
.
visible_toolbar_buttons
.
call
=
true
;
// enable the button
utils
.
openChatBoxFor
(
contact_jid
);
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -360,7 +360,7 @@
callButton
=
$toolbar
.
find
(
'
.toggle-call
'
);
expect
(
callButton
.
length
).
toBe
(
1
);
callButton
.
click
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
allButtonClicked
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
allButtonClicked
'
,
jasmine
.
any
(
Object
));
},
converse
));
it
(
"
can contain a button for clearing messages
"
,
$
.
proxy
(
function
()
{
...
...
@@ -420,7 +420,7 @@
runs
(
$
.
proxy
(
function
()
{
// onMessage is a handler for received XMPP messages
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
msg
);
},
converse
));
waits
(
250
);
runs
(
$
.
proxy
(
function
()
{
...
...
@@ -473,7 +473,7 @@
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
msg
);
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
msg
);
},
converse
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
...
...
@@ -535,7 +535,7 @@
.
c
(
'
delay
'
,
{
xmlns
:
'
urn:xmpp:delay
'
,
from
:
'
localhost
'
,
stamp
:
one_day_ago
.
format
()
})
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
msg
);
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
...
...
@@ -556,7 +556,7 @@
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
msg
);
// Check that there is a <time> element, with the required
// props.
var
$time
=
$chat_content
.
find
(
'
time
'
);
...
...
@@ -587,14 +587,14 @@
});
waits
(
250
);
runs
(
function
()
{
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxFocused
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxFocused
'
,
jasmine
.
any
(
Object
));
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
var
message
=
'
This message is sent from this chatbox
'
;
spyOn
(
view
,
'
sendMessage
'
).
andCallThrough
();
utils
.
sendMessage
(
view
,
message
);
expect
(
view
.
sendMessage
).
toHaveBeenCalled
();
expect
(
view
.
model
.
messages
.
length
,
2
);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
onM
essageSend
'
,
message
]);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
m
essageSend
'
,
message
]);
expect
(
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
).
text
()).
toEqual
(
message
);
}.
bind
(
converse
));
},
converse
));
...
...
@@ -709,7 +709,7 @@
utils
.
sendMessage
(
view
,
message
);
expect
(
view
.
model
.
messages
.
length
>
0
).
toBeTruthy
();
expect
(
view
.
model
.
messages
.
browserStorage
.
records
.
length
>
0
).
toBeTruthy
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essageSend
'
,
message
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essageSend
'
,
message
);
message
=
'
/clear
'
;
var
old_length
=
view
.
model
.
messages
.
length
;
...
...
@@ -725,7 +725,7 @@
expect
(
view
.
model
.
messages
.
length
,
0
);
// The messages must be removed from the chatbox
expect
(
view
.
model
.
messages
.
browserStorage
.
records
.
length
,
0
);
// And also from browserStorage
expect
(
converse
.
emit
.
callCount
,
1
);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
onM
essageSend
'
,
message
]);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
m
essageSend
'
,
message
]);
},
converse
));
},
converse
));
...
...
@@ -751,7 +751,7 @@
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
incrementMsgCounter
).
toHaveBeenCalled
();
expect
(
this
.
msg_counter
).
toBe
(
1
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
msg
);
},
converse
));
it
(
"
is cleared when the window is focused
"
,
$
.
proxy
(
function
()
{
...
...
spec/chatroom.js
View file @
df91f178
...
...
@@ -85,7 +85,7 @@
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
find
(
'
.chat-message
'
).
length
).
toBe
(
1
);
expect
(
$chat_content
.
find
(
'
.chat-message-content
'
).
text
()).
toBe
(
text
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essage
'
,
message
.
nodeTree
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essage
'
,
message
.
nodeTree
);
},
converse
));
it
(
"
shows sent groupchat messages
"
,
$
.
proxy
(
function
()
{
...
...
@@ -96,7 +96,7 @@
var
text
=
'
This is a sent message
'
;
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
text
);
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onM
essageSend
'
,
text
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
m
essageSend
'
,
text
);
var
message
=
$msg
({
from
:
'
lounge@muc.localhost/dummy
'
,
...
...
@@ -152,7 +152,7 @@
waits
(
50
);
runs
(
function
()
{
expect
(
view
.
minimize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
.
callCount
,
2
);
expect
(
view
.
$el
.
is
(
'
:visible
'
)).
toBeFalsy
();
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
...
...
@@ -163,7 +163,7 @@
waits
(
250
);
runs
(
function
()
{
expect
(
view
.
maximize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
view
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
converse
.
emit
.
callCount
,
3
);
...
...
@@ -184,7 +184,7 @@
runs
(
function
()
{
expect
(
view
.
close
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
muc
.
leave
).
toHaveBeenCalled
();
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
onC
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
c
hatBoxClosed
'
,
jasmine
.
any
(
Object
));
}.
bind
(
converse
));
},
converse
));
},
converse
));
...
...
spec/controlbox.js
View file @
df91f178
...
...
@@ -34,7 +34,7 @@
runs
(
function
()
{
expect
(
this
.
controlboxtoggle
.
onClick
).
toHaveBeenCalled
();
expect
(
this
.
controlboxtoggle
.
showControlBox
).
toHaveBeenCalled
();
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
onC
ontrolBoxOpened
'
,
jasmine
.
any
(
Object
));
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
c
ontrolBoxOpened
'
,
jasmine
.
any
(
Object
));
expect
(
$
(
"
div#controlbox
"
).
is
(
'
:visible
'
)).
toBe
(
true
);
}.
bind
(
converse
));
},
converse
));
...
...
@@ -67,7 +67,7 @@
view
.
initialize
();
// Rebind events for spy
$
(
view
.
$el
.
find
(
'
.dropdown dd ul li a
'
)[
1
]).
click
();
// Change status to "dnd"
expect
(
view
.
setStatus
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onS
tatusChanged
'
,
'
dnd
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
s
tatusChanged
'
,
'
dnd
'
);
});
waits
(
250
);
runs
(
$
.
proxy
(
function
()
{
...
...
@@ -97,7 +97,7 @@
runs
(
function
()
{
view
.
$el
.
find
(
'
form#set-custom-xmpp-status
'
).
submit
();
expect
(
view
.
setStatusMessage
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onS
tatusMessageChanged
'
,
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
s
tatusMessageChanged
'
,
msg
);
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
hasClass
(
'
online
'
)).
toBe
(
true
);
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
attr
(
'
data-value
'
)).
toBe
(
msg
);
});
...
...
@@ -143,7 +143,7 @@
},
converse
));
waits
(
300
);
runs
(
$
.
proxy
(
function
()
{
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
expect
(
this
.
rosterview
.
$el
.
is
(
'
:visible
'
)).
toEqual
(
true
);
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
},
converse
));
...
...
@@ -165,7 +165,7 @@
expect
(
this
.
rosterview
.
model
.
remove
).
toHaveBeenCalled
();
// The element must now be detached from the DOM.
expect
(
view
.
$el
.
closest
(
'
html
'
).
length
).
toBeFalsy
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
},
converse
));
it
(
"
will lose their own heading once the last one has been removed
"
,
$
.
proxy
(
function
()
{
...
...
@@ -193,7 +193,7 @@
is_last
:
is_last
});
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
siblings
(
'
dd.pending-xmpp-contact
'
).
find
(
'
span
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
pend_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -233,7 +233,7 @@
is_last
:
i
===
(
mock
.
cur_names
.
length
-
1
)
});
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.offline
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -256,7 +256,7 @@
item
.
set
(
'
chat_status
'
,
'
online
'
);
expect
(
view
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.online
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -275,7 +275,7 @@
item
.
set
(
'
chat_status
'
,
'
dnd
'
);
expect
(
view
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.dnd
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -294,7 +294,7 @@
item
.
set
(
'
chat_status
'
,
'
away
'
);
expect
(
view
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.away
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -313,7 +313,7 @@
item
.
set
(
'
chat_status
'
,
'
xa
'
);
expect
(
view
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.xa
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -332,7 +332,7 @@
item
.
set
(
'
chat_status
'
,
'
unavailable
'
);
expect
(
view
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.unavailable
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
mock
.
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
...
...
@@ -430,7 +430,7 @@
// When a requesting contact is added, the controlbox must
// be opened.
expect
(
this
.
controlboxtoggle
.
showControlBox
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
}
},
converse
));
...
...
@@ -466,7 +466,7 @@
expect
(
view
.
declineRequest
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
removeRosterItemView
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onR
osterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
r
osterViewUpdated
'
);
// There should now be one less contact
expect
(
this
.
roster
.
length
).
toEqual
(
mock
.
req_names
.
length
-
1
);
},
converse
));
...
...
spec/eventemitter.js
View file @
df91f178
...
...
@@ -14,24 +14,24 @@
it
(
"
allows you to subscribe to emitted events
"
,
function
()
{
this
.
callback
=
function
()
{};
spyOn
(
this
,
'
callback
'
);
converse
.
on
(
'
onI
nitialized
'
,
this
.
callback
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
on
(
'
i
nitialized
'
,
this
.
callback
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
2
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
3
);
});
it
(
"
allows you to listen once for an emitted event
"
,
function
()
{
this
.
callback
=
function
()
{};
spyOn
(
this
,
'
callback
'
);
converse
.
once
(
'
onI
nitialized
'
,
this
.
callback
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
once
(
'
i
nitialized
'
,
this
.
callback
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
1
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
1
);
});
...
...
@@ -43,23 +43,23 @@
spyOn
(
this
,
'
callback
'
);
spyOn
(
this
,
'
anotherCallback
'
);
spyOn
(
this
,
'
neverCalled
'
);
converse
.
on
(
'
onI
nitialized
'
,
this
.
callback
);
converse
.
on
(
'
onI
nitialized
'
,
this
.
anotherCallback
);
converse
.
on
(
'
i
nitialized
'
,
this
.
callback
);
converse
.
on
(
'
i
nitialized
'
,
this
.
anotherCallback
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
expect
(
this
.
anotherCallback
).
toHaveBeenCalled
();
converse
.
off
(
'
onI
nitialized
'
,
this
.
callback
);
converse
.
off
(
'
i
nitialized
'
,
this
.
callback
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
1
);
expect
(
this
.
anotherCallback
.
callCount
,
2
);
converse
.
once
(
'
onI
nitialized
'
,
this
.
neverCalled
);
converse
.
off
(
'
onI
nitialized
'
,
this
.
neverCalled
);
converse
.
once
(
'
i
nitialized
'
,
this
.
neverCalled
);
converse
.
off
(
'
i
nitialized
'
,
this
.
neverCalled
);
converse
.
emit
(
'
onI
nitialized
'
);
converse
.
emit
(
'
i
nitialized
'
);
expect
(
this
.
callback
.
callCount
,
1
);
expect
(
this
.
anotherCallback
.
callCount
,
3
);
expect
(
this
.
neverCalled
).
not
.
toHaveBeenCalled
();
...
...
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