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
e3cb6f3f
Commit
e3cb6f3f
authored
Oct 07, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use .bind instead of $.proxy
parent
eeb8210f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
159 additions
and
159 deletions
+159
-159
spec/chatbox.js
spec/chatbox.js
+108
-108
spec/chatroom.js
spec/chatroom.js
+51
-51
No files found.
spec/chatbox.js
View file @
e3cb6f3f
...
...
@@ -13,7 +13,7 @@
var
moment
=
converse_api
.
env
.
moment
;
return
describe
(
"
Chatboxes
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
A Chatbox
"
,
$
.
proxy
(
function
()
{
describe
(
"
A Chatbox
"
,
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
test_utils
.
closeAllChatBoxes
();
...
...
@@ -26,7 +26,7 @@
});
});
it
(
"
is created when you click on a roster item
"
,
$
.
proxy
(
function
()
{
it
(
"
is created when you click on a roster item
"
,
function
()
{
var
i
,
$el
,
click
,
jid
,
chatboxview
;
// openControlBox was called earlier, so the controlbox is
// visible, but no other chat boxes have been created.
...
...
@@ -47,9 +47,9 @@
expect
(
$
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
i
+
2
);
expect
(
$
(
"
#conversejs .chatbox
"
)[
1
].
id
).
toBe
(
chatboxview
.
model
.
get
(
'
box_id
'
));
}
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be trimmed to conserve space
"
,
$
.
proxy
(
function
()
{
it
(
"
can be trimmed to conserve space
"
,
function
()
{
var
i
,
$el
,
click
,
jid
,
key
,
chatbox
,
chatboxview
;
// openControlBox was called earlier, so the controlbox is
// visible, but no other chat boxes have been created.
...
...
@@ -61,11 +61,11 @@
expect
(
$
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
1
);
// Controlbox is open
// Test that they can be trimmed
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
update
();
// XXX: Hack to make sure $roster element is attaced.
}
,
this
));
}
.
bind
(
this
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
// Test that they can be maximized again
var
online_contacts
=
this
.
rosterview
.
$el
.
find
(
'
dt.roster-group
'
).
siblings
(
'
dd.current-xmpp-contact
'
).
find
(
'
a.open-chat
'
);
for
(
i
=
0
;
i
<
online_contacts
.
length
;
i
++
)
{
...
...
@@ -88,16 +88,16 @@
spyOn
(
trimmedview
,
'
restore
'
).
andCallThrough
();
trimmedview
.
delegateEvents
();
trimmedview
.
$
(
"
a.restore-chat
"
).
click
();
}
,
this
));
}
.
bind
(
this
));
waits
(
250
);
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
expect
(
trimmedview
.
restore
).
toHaveBeenCalled
();
expect
(
chatbox
.
maximize
).
toHaveBeenCalled
();
expect
(
this
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
}
,
this
));
}
,
converse
));
}
.
bind
(
this
));
}
.
bind
(
converse
));
it
(
"
is focused if its already open and you click on its corresponding roster item
"
,
$
.
proxy
(
function
()
{
it
(
"
is focused if its already open and you click on its corresponding roster item
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
i
,
$el
,
click
,
jid
,
chatboxview
,
chatbox
;
// openControlBox was called earlier, so the controlbox is
...
...
@@ -108,20 +108,20 @@
spyOn
(
chatboxview
,
'
focus
'
);
// Test that they can be trimmed
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
update
();
// XXX: Hack to make sure $roster element is attaced.
}
,
this
));
}
.
bind
(
this
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
$el
=
this
.
rosterview
.
$el
.
find
(
'
a.open-chat:contains("
'
+
chatbox
.
get
(
'
fullname
'
)
+
'
")
'
);
jid
=
$el
.
text
().
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
$el
.
click
();
expect
(
this
.
chatboxes
.
length
).
toEqual
(
2
);
expect
(
chatboxview
.
focus
).
toHaveBeenCalled
();
}
,
this
));
}
,
converse
));
}
.
bind
(
this
));
}
.
bind
(
converse
));
it
(
"
can be saved to, and retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
it
(
"
can be saved to, and retrieved from, browserStorage
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
chatboxviews
,
'
trimChats
'
);
runs
(
function
()
{
...
...
@@ -149,9 +149,9 @@
}
this
.
rosterview
.
render
();
}.
bind
(
converse
));
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be closed by clicking a DOM element with class 'close-chatbox-button'
"
,
$
.
proxy
(
function
()
{
it
(
"
can be closed by clicking a DOM element with class 'close-chatbox-button'
"
,
function
()
{
var
chatbox
=
test_utils
.
openChatBoxes
(
1
)[
0
],
controlview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
),
// The controlbox is currently open
chatview
=
this
.
chatboxviews
.
get
(
chatbox
.
get
(
'
jid
'
));
...
...
@@ -179,7 +179,7 @@
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
converse
.
emit
.
callCount
,
2
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be minimized by clicking a DOM element with class 'toggle-chatbox-button'
"
,
function
()
{
var
chatbox
=
test_utils
.
openChatBoxes
(
1
)[
0
],
...
...
@@ -218,7 +218,7 @@
});
}.
bind
(
converse
));
it
(
"
will be removed from browserStorage when closed
"
,
$
.
proxy
(
function
()
{
it
(
"
will be removed from browserStorage when closed
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
.
chatboxviews
,
'
trimChats
'
);
this
.
chatboxes
.
browserStorage
.
_clear
();
...
...
@@ -251,10 +251,10 @@
expect
(
newchatboxes
.
length
).
toEqual
(
1
);
expect
(
newchatboxes
.
models
[
0
].
id
).
toBe
(
"
controlbox
"
);
}.
bind
(
converse
));
}
,
converse
));
}
.
bind
(
converse
));
describe
(
"
A chat toolbar
"
,
$
.
proxy
(
function
()
{
it
(
"
can be found on each chat box
"
,
$
.
proxy
(
function
()
{
describe
(
"
A chat toolbar
"
,
function
()
{
it
(
"
can be found on each chat box
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
chatbox
=
this
.
chatboxes
.
get
(
contact_jid
);
...
...
@@ -264,9 +264,9 @@
var
$toolbar
=
view
.
$el
.
find
(
'
ul.chat-toolbar
'
);
expect
(
$toolbar
.
length
).
toBe
(
1
);
expect
(
$toolbar
.
children
(
'
li
'
).
length
).
toBe
(
3
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
contains a button for inserting emoticons
"
,
$
.
proxy
(
function
()
{
it
(
"
contains a button for inserting emoticons
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -322,9 +322,9 @@
expect
(
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
expect
(
$textarea
.
val
()).
toBe
(
'
:) <3
'
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
contains a button for starting an encrypted chat session
"
,
$
.
proxy
(
function
()
{
it
(
"
contains a button for starting an encrypted chat session
"
,
function
()
{
// TODO: More tests can be added here...
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
...
...
@@ -346,9 +346,9 @@
expect
(
$menu
.
children
(
'
li
'
).
length
).
toBe
(
2
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can contain a button for starting a call
"
,
$
.
proxy
(
function
()
{
it
(
"
can contain a button for starting a call
"
,
function
()
{
var
view
,
callButton
,
$toolbar
;
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
spyOn
(
converse
,
'
emit
'
);
...
...
@@ -371,9 +371,9 @@
expect
(
callButton
.
length
).
toBe
(
1
);
callButton
.
click
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
callButtonClicked
'
,
jasmine
.
any
(
Object
));
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can contain a button for clearing messages
"
,
$
.
proxy
(
function
()
{
it
(
"
can contain a button for clearing messages
"
,
function
()
{
var
view
,
clearButton
,
$toolbar
;
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
// First check that the button doesn't show if it's not enabled
...
...
@@ -398,11 +398,11 @@
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
clearButton
.
click
();
expect
(
view
.
clearMessages
).
toHaveBeenCalled
();
}
,
converse
));
}
.
bind
(
converse
));
}
,
converse
));
}
.
bind
(
converse
));
describe
(
"
A Chat Message
"
,
$
.
proxy
(
function
()
{
describe
(
"
A Chat Message
"
,
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
...
...
@@ -412,7 +412,7 @@
runs
(
function
()
{});
});
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
$
.
proxy
(
function
()
{
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
message
=
'
This is a received message
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -427,13 +427,13 @@
// We don't already have an open chatbox for this user
expect
(
this
.
chatboxes
.
get
(
sender_jid
)).
not
.
toBeDefined
();
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
// onMessage is a handler for received XMPP messages
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
msg
);
}
,
converse
));
}
.
bind
(
converse
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
// Check that the chatbox and its view now exist
var
chatbox
=
this
.
chatboxes
.
get
(
sender_jid
);
var
chatboxview
=
this
.
chatboxviews
.
get
(
sender_jid
);
...
...
@@ -454,8 +454,8 @@
expect
(
msg_txt
).
toEqual
(
message
);
var
sender_txt
=
$chat_content
.
find
(
'
span.chat-message-them
'
).
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
it
(
"
is ignored if it's intended for a different resource
"
,
function
()
{
// Send a message from a different resource
...
...
@@ -553,7 +553,7 @@
expect
(
msg_txt
).
toEqual
(
msgtext
);
});
it
(
"
received for a minimized chat box will increment a counter on its header
"
,
$
.
proxy
(
function
()
{
it
(
"
received for a minimized chat box will increment a counter on its header
"
,
function
()
{
var
contact_name
=
mock
.
cur_names
[
0
];
var
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
spyOn
(
this
,
'
emit
'
);
...
...
@@ -597,9 +597,9 @@
expect
(
$count
.
html
()).
toBe
(
'
2
'
);
trimmedview
.
$el
.
find
(
'
.restore-chat
'
).
click
();
expect
(
trimmed_chatboxes
.
keys
().
length
).
toBe
(
0
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will indicate when it has a time difference of more than a day between it and its predecessor
"
,
$
.
proxy
(
function
()
{
it
(
"
will indicate when it has a time difference of more than a day between it and its predecessor
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
contact_name
=
mock
.
cur_names
[
1
];
var
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -666,9 +666,9 @@
expect
(
msg_txt
).
toEqual
(
message
);
sender_txt
=
$chat_content
.
find
(
'
span.chat-message-them
'
).
last
().
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be sent from a chatbox, and will appear inside it
"
,
$
.
proxy
(
function
()
{
it
(
"
can be sent from a chatbox, and will appear inside it
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
...
...
@@ -681,9 +681,9 @@
expect
(
view
.
model
.
messages
.
length
,
2
);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
messageSend
'
,
message
]);
expect
(
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
).
text
()).
toEqual
(
message
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is sanitized to prevent Javascript injection attacks
"
,
$
.
proxy
(
function
()
{
it
(
"
is sanitized to prevent Javascript injection attacks
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -694,9 +694,9 @@
var
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
);
expect
(
msg
.
text
()).
toEqual
(
message
);
expect
(
msg
.
html
()).
toEqual
(
'
<p>This message contains <em>some</em> <b>markup</b></p>
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can contain hyperlinks, which will be clickable
"
,
$
.
proxy
(
function
()
{
it
(
"
can contain hyperlinks, which will be clickable
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -707,9 +707,9 @@
var
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
);
expect
(
msg
.
text
()).
toEqual
(
message
);
expect
(
msg
.
html
()).
toEqual
(
'
This message contains a hyperlink: <a target="_blank" href="http://www.opkode.com">www.opkode.com</a>
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
should display emoticons correctly
"
,
$
.
proxy
(
function
()
{
it
(
"
should display emoticons correctly
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -731,9 +731,9 @@
var
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
);
expect
(
msg
.
html
()).
toEqual
(
emoticons
[
i
]);
}
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will have properly escaped URLs
"
,
$
.
proxy
(
function
()
{
it
(
"
will have properly escaped URLs
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -766,9 +766,9 @@
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
);
expect
(
msg
.
text
()).
toEqual
(
message
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" href="https://en.wikipedia.org/wiki/Ender%27s_Game">https://en.wikipedia.org/wiki/Ender%27s_Game</a>
'
);
}
,
converse
));
}
.
bind
(
converse
));
}
,
converse
));
}
.
bind
(
converse
));
describe
(
"
An OTR Chat Message
"
,
function
()
{
...
...
@@ -788,9 +788,9 @@
});
});
describe
(
"
A Chat Status Notification
"
,
$
.
proxy
(
function
()
{
describe
(
"
A Chat Status Notification
"
,
function
()
{
it
(
"
does not open automatically if a chat state notification is received
"
,
$
.
proxy
(
function
()
{
it
(
"
does not open automatically if a chat state notification is received
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
// <composing> state
...
...
@@ -805,10 +805,10 @@
var
chatboxview
=
this
.
chatboxviews
.
get
(
sender_jid
);
expect
(
chatboxview
).
toBeDefined
();
expect
(
chatboxview
.
$el
.
is
(
'
:visible
'
)).
toBeFalsy
();
// The chat box is not visible
}
,
converse
));
}
.
bind
(
converse
));
describe
(
"
An active notification
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent when the user opens a chat box
"
,
$
.
proxy
(
function
()
{
describe
(
"
An active notification
"
,
function
()
{
it
(
"
is sent when the user opens a chat box
"
,
function
()
{
spyOn
(
converse
.
connection
,
'
send
'
);
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
...
...
@@ -819,9 +819,9 @@
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
().
prop
(
'
tagName
'
)).
toBe
(
'
active
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is sent when the user maximizes a minimized a chat box
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent when the user maximizes a minimized a chat box
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -835,11 +835,11 @@
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
().
prop
(
'
tagName
'
)).
toBe
(
'
active
'
);
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
A composing notification
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent as soon as the user starts typing a message which is not a command
"
,
$
.
proxy
(
function
()
{
describe
(
"
A composing notification
"
,
function
()
{
it
(
"
is sent as soon as the user starts typing a message which is not a command
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -863,9 +863,9 @@
});
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
composing
'
);
expect
(
converse
.
emit
.
callCount
,
1
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will be shown if received
"
,
$
.
proxy
(
function
()
{
it
(
"
will be shown if received
"
,
function
()
{
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
converse
,
'
emit
'
);
var
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -885,11 +885,11 @@
var
$events
=
chatboxview
.
$el
.
find
(
'
.chat-event
'
);
expect
(
$events
.
length
).
toBe
(
1
);
expect
(
$events
.
text
()).
toEqual
(
mock
.
cur_names
[
1
].
split
(
'
'
)[
0
]
+
'
is typing
'
);
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
A paused notification
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent if the user has stopped typing since 30 seconds
"
,
$
.
proxy
(
function
()
{
describe
(
"
A paused notification
"
,
function
()
{
it
(
"
is sent if the user has stopped typing since 30 seconds
"
,
function
()
{
this
.
TIMEOUTS
.
PAUSED
=
200
;
// Make the timeout shorter so that we can test
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
...
...
@@ -937,9 +937,9 @@
runs
(
function
()
{
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
composing
'
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will be shown if received
"
,
$
.
proxy
(
function
()
{
it
(
"
will be shown if received
"
,
function
()
{
// TODO: only show paused state if the previous state was composing
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
converse
,
'
emit
'
);
...
...
@@ -957,11 +957,11 @@
$events
=
chatboxview
.
$el
.
find
(
'
.chat-event
'
);
expect
(
$events
.
length
).
toBe
(
1
);
expect
(
$events
.
text
()).
toEqual
(
mock
.
cur_names
[
1
].
split
(
'
'
)[
0
]
+
'
has stopped typing
'
);
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
An inactive notifciation
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
$
.
proxy
(
function
()
{
describe
(
"
An inactive notifciation
"
,
function
()
{
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
function
()
{
// Make the timeouts shorter so that we can test
this
.
TIMEOUTS
.
PAUSED
=
200
;
this
.
TIMEOUTS
.
INACTIVE
=
200
;
...
...
@@ -990,9 +990,9 @@
expect
(
$stanza
.
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
().
prop
(
'
tagName
'
)).
toBe
(
'
inactive
'
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is sent when the user a minimizes a chat box
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent when the user a minimizes a chat box
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -1004,9 +1004,9 @@
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
().
prop
(
'
tagName
'
)).
toBe
(
'
inactive
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is sent if the user closes a chat box
"
,
$
.
proxy
(
function
()
{
it
(
"
is sent if the user closes a chat box
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
this
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -1019,9 +1019,9 @@
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
().
prop
(
'
tagName
'
)).
toBe
(
'
inactive
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will clear any other chat status notifications if its received
"
,
$
.
proxy
(
function
()
{
it
(
"
will clear any other chat status notifications if its received
"
,
function
()
{
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
converse
,
'
emit
'
);
var
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -1039,12 +1039,12 @@
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
msg
);
expect
(
view
.
$el
.
find
(
'
.chat-event
'
).
length
).
toBe
(
0
);
}
,
converse
));
}
.
bind
(
converse
));
}
,
converse
));
}
.
bind
(
converse
));
describe
(
"
A gone notifciation
"
,
$
.
proxy
(
function
()
{
it
(
"
will be shown if received
"
,
$
.
proxy
(
function
()
{
describe
(
"
A gone notifciation
"
,
function
()
{
it
(
"
will be shown if received
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
// <paused> state
...
...
@@ -1060,12 +1060,12 @@
$events
=
chatboxview
.
$el
.
find
(
'
.chat-event
'
);
expect
(
$events
.
length
).
toBe
(
1
);
expect
(
$events
.
text
()).
toEqual
(
mock
.
cur_names
[
1
].
split
(
'
'
)[
0
]
+
'
has gone away
'
);
}
,
converse
));
}
,
converse
));
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
Special Messages
"
,
$
.
proxy
(
function
()
{
describe
(
"
Special Messages
"
,
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeAllChatBoxes
();
test_utils
.
removeControlBox
();
...
...
@@ -1076,7 +1076,7 @@
test_utils
.
openContactsPanel
();
});
it
(
"
'/clear' can be used to clear messages in a conversation
"
,
$
.
proxy
(
function
()
{
it
(
"
'/clear' can be used to clear messages in a conversation
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
contact_jid
);
...
...
@@ -1104,15 +1104,15 @@
expect
(
view
.
model
.
messages
.
browserStorage
.
records
.
length
,
0
);
// And also from browserStorage
expect
(
converse
.
emit
.
callCount
,
1
);
expect
(
converse
.
emit
.
mostRecentCall
.
args
,
[
'
messageSend
'
,
message
]);
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
A Message Counter
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
describe
(
"
A Message Counter
"
,
function
()
{
beforeEach
(
function
()
{
converse
.
clearMsgCounter
();
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is incremented when the message is received and the window is not focused
"
,
$
.
proxy
(
function
()
{
it
(
"
is incremented when the message is received and the window is not focused
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
expect
(
this
.
msg_counter
).
toBe
(
0
);
spyOn
(
converse
,
'
incrementMsgCounter
'
).
andCallThrough
();
...
...
@@ -1130,9 +1130,9 @@
expect
(
converse
.
incrementMsgCounter
).
toHaveBeenCalled
();
expect
(
this
.
msg_counter
).
toBe
(
1
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
msg
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is cleared when the window is focused
"
,
$
.
proxy
(
function
()
{
it
(
"
is cleared when the window is focused
"
,
function
()
{
spyOn
(
converse
,
'
clearMsgCounter
'
).
andCallThrough
();
runs
(
function
()
{
$
(
window
).
triggerHandler
(
'
blur
'
);
...
...
@@ -1142,9 +1142,9 @@
runs
(
function
()
{
expect
(
converse
.
clearMsgCounter
).
toHaveBeenCalled
();
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
is not incremented when the message is received and the window is focused
"
,
$
.
proxy
(
function
()
{
it
(
"
is not incremented when the message is received and the window is focused
"
,
function
()
{
expect
(
this
.
msg_counter
).
toBe
(
0
);
spyOn
(
converse
,
'
incrementMsgCounter
'
).
andCallThrough
();
$
(
window
).
trigger
(
'
focus
'
);
...
...
@@ -1160,7 +1160,7 @@
this
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
incrementMsgCounter
).
not
.
toHaveBeenCalled
();
expect
(
this
.
msg_counter
).
toBe
(
0
);
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
},
converse
,
mock
,
test_utils
));
}));
spec/chatroom.js
View file @
e3cb6f3f
...
...
@@ -13,8 +13,8 @@
var
$msg
=
converse_api
.
env
.
$msg
;
var
Strophe
=
converse_api
.
env
.
Strophe
;
return
describe
(
"
ChatRooms
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
A Chat Room
"
,
$
.
proxy
(
function
()
{
return
describe
(
"
ChatRooms
"
,
function
(
mock
,
test_utils
)
{
describe
(
"
A Chat Room
"
,
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
test_utils
.
closeAllChatBoxes
();
...
...
@@ -29,7 +29,7 @@
expect
(
view
instanceof
converse
.
ChatRoomView
).
toBe
(
true
);
});
it
(
"
shows users currently present in the room
"
,
$
.
proxy
(
function
()
{
it
(
"
shows users currently present in the room
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
name
;
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
),
...
...
@@ -79,9 +79,9 @@
expect
(
view
.
onChatRoomPresence
).
toHaveBeenCalled
();
expect
(
$participants
.
find
(
'
li
'
).
length
).
toBe
(
i
);
}
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
indicates moderators by means of a special css class and tooltip
"
,
$
.
proxy
(
function
()
{
it
(
"
indicates moderators by means of a special css class and tooltip
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
...
...
@@ -102,9 +102,9 @@
expect
(
$
(
occupant
).
text
()).
toBe
(
"
moderatorman
"
);
expect
(
$
(
occupant
).
attr
(
'
class
'
)).
toBe
(
'
moderator
'
);
expect
(
$
(
occupant
).
attr
(
'
title
'
)).
toBe
(
'
This user is a moderator
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
allows the user to invite their roster contacts to enter the chat room
"
,
$
.
proxy
(
function
()
{
it
(
"
allows the user to invite their roster contacts to enter the chat room
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
window
,
'
prompt
'
).
andCallFake
(
function
()
{
...
...
@@ -132,9 +132,9 @@
$sugg
.
trigger
(
'
click
'
);
expect
(
window
.
prompt
).
toHaveBeenCalled
();
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be joined automatically, based upon a received invite
"
,
$
.
proxy
(
function
()
{
it
(
"
can be joined automatically, based upon a received invite
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
window
,
'
confirm
'
).
andCallFake
(
function
()
{
return
true
;
...
...
@@ -162,9 +162,9 @@
expect
(
converse
.
chatboxes
.
models
.
length
).
toBe
(
2
);
expect
(
converse
.
chatboxes
.
models
[
0
].
id
).
toBe
(
'
controlbox
'
);
expect
(
converse
.
chatboxes
.
models
[
1
].
id
).
toBe
(
room_jid
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
shows received groupchat messages
"
,
$
.
proxy
(
function
()
{
it
(
"
shows received groupchat messages
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
converse
,
'
emit
'
);
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
...
...
@@ -182,9 +182,9 @@
expect
(
$chat_content
.
find
(
'
.chat-message
'
).
length
).
toBe
(
1
);
expect
(
$chat_content
.
find
(
'
.chat-message-content
'
).
text
()).
toBe
(
text
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
message
.
nodeTree
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
plays a sound when the current user is mentioned (if configured)
"
,
$
.
proxy
(
function
()
{
it
(
"
plays a sound when the current user is mentioned (if configured)
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
converse
,
'
emit
'
);
converse
.
play_sounds
=
true
;
...
...
@@ -223,9 +223,9 @@
view
.
onChatRoomMessage
(
message
.
nodeTree
);
expect
(
converse
.
playNotification
,
1
);
converse
.
play_sounds
=
false
;
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
shows sent groupchat messages
"
,
$
.
proxy
(
function
()
{
it
(
"
shows sent groupchat messages
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
converse
,
'
emit
'
);
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
...
...
@@ -248,9 +248,9 @@
expect
(
$chat_content
.
find
(
'
.chat-message-content
'
).
last
().
text
()).
toBe
(
text
);
// We don't emit an event if it's our own message
expect
(
converse
.
emit
.
callCount
,
1
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
informs users if their nicknames has been changed.
"
,
$
.
proxy
(
function
()
{
it
(
"
informs users if their nicknames has been changed.
"
,
function
()
{
/* The service then sends two presence stanzas to the full JID
* of each occupant (including the occupant who is changing his
* or her room nickname), one of type "unavailable" for the old
...
...
@@ -286,7 +286,7 @@
* </x>
* </presence>
*/
var
__
=
$
.
proxy
(
utils
.
__
,
converse
);
var
__
=
utils
.
__
.
bind
(
converse
);
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
oldnick
'
);
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
...
...
@@ -360,9 +360,9 @@
$participants
=
view
.
$
(
'
.participant-list
'
);
expect
(
$participants
.
children
().
length
).
toBe
(
1
);
expect
(
$participants
.
children
().
first
(
0
).
text
()).
toBe
(
"
newnick
"
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
informs users if they have been kicked out of the chat room
"
,
$
.
proxy
(
function
()
{
it
(
"
informs users if they have been kicked out of the chat room
"
,
function
()
{
/* <presence
* from='harfleur@chat.shakespeare.lit/pistol'
* to='pistol@shakespeare.lit/harfleur'
...
...
@@ -399,9 +399,9 @@
expect
(
view
.
$
(
'
.participants
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
var
$chat_body
=
view
.
$
(
'
.chat-body
'
);
expect
(
$chat_body
.
html
().
trim
().
indexOf
(
'
<p>You have been kicked from this room</p><p>The reason given is: "Avaunt, you cullion!"</p>
'
)).
not
.
toBe
(
-
1
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be saved to, and retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
it
(
"
can be saved to, and retrieved from, browserStorage
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
// We instantiate a new ChatBoxes collection, which by default
// will be empty.
...
...
@@ -425,7 +425,7 @@
expect
(
_
.
isEqual
(
new_attrs
.
sort
(),
old_attrs
.
sort
())).
toEqual
(
true
);
}
this
.
rosterview
.
render
();
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
can be minimized by clicking a DOM element with class 'toggle-chatbox-button'
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
...
@@ -460,7 +460,7 @@
}.
bind
(
converse
));
it
(
"
can be closed again by clicking a DOM element with class 'close-chatbox-button'
"
,
$
.
proxy
(
function
()
{
it
(
"
can be closed again by clicking a DOM element with class 'close-chatbox-button'
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
this
.
chatboxviews
.
get
(
'
lounge@localhost
'
),
chatroom
=
view
.
model
,
$el
;
spyOn
(
view
,
'
close
'
).
andCallThrough
();
...
...
@@ -476,11 +476,11 @@
expect
(
view
.
leave
).
toHaveBeenCalled
();
expect
(
this
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
}.
bind
(
converse
));
}
,
converse
));
}
,
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
describe
(
"
When attempting to enter a chatroom
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
describe
(
"
When attempting to enter a chatroom
"
,
function
()
{
beforeEach
(
function
()
{
var
roomspanel
=
this
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
var
$input
=
roomspanel
.
$el
.
find
(
'
input.new-chatroom-name
'
);
var
$nick
=
roomspanel
.
$el
.
find
(
'
input.new-chatroom-nick
'
);
...
...
@@ -489,14 +489,14 @@
$nick
.
val
(
'
dummy
'
);
$server
.
val
(
'
muc.localhost
'
);
roomspanel
.
$el
.
find
(
'
form
'
).
submit
();
}
,
converse
));
}
.
bind
(
converse
));
afterEach
(
$
.
proxy
(
function
()
{
afterEach
(
function
()
{
var
view
=
this
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
view
.
close
();
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the room requires a password
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the room requires a password
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -518,9 +518,9 @@
expect
(
$chat_body
.
find
(
'
form.chatroom-form
'
).
length
).
toBe
(
1
);
expect
(
$chat_body
.
find
(
'
legend
'
).
text
()).
toBe
(
'
This chatroom requires a password
'
);
});
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the room is members-only and the user not included
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the room is members-only and the user not included
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -533,9 +533,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
'
You are not on the member list of this room
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the user has been banned
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the user has been banned
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -548,9 +548,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
'
You have been banned from this room
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if no nickname was specified for the user
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if no nickname was specified for the user
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -563,9 +563,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
'
No nickname was specified
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the user is not allowed to have created the room
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the user is not allowed to have created the room
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -578,9 +578,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
'
You are not allowed to create new rooms
'
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the user's nickname doesn't conform to room policy
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the user's nickname doesn't conform to room policy
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -593,9 +593,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
"
Your nickname doesn't conform to this room's policies
"
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the user's nickname is already taken
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the user's nickname is already taken
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -608,9 +608,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
"
Your nickname is already taken
"
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the room doesn't yet exist
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the room doesn't yet exist
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -623,9 +623,9 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
"
This room does not (yet) exist
"
);
}
,
converse
));
}
.
bind
(
converse
));
it
(
"
will show an error message if the room has reached it's maximum number of occupants
"
,
$
.
proxy
(
function
()
{
it
(
"
will show an error message if the room has reached it's maximum number of occupants
"
,
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/thirdwitch
'
,
id
:
'
n13mt3l
'
,
...
...
@@ -638,7 +638,7 @@
spyOn
(
view
,
'
showErrorMessage
'
).
andCallThrough
();
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
expect
(
view
.
$el
.
find
(
'
.chat-body p
'
).
text
()).
toBe
(
"
This room has reached it's maximum number of occupants
"
);
}
,
converse
));
}
,
converse
));
}
,
converse
,
mock
,
test_utils
));
}
.
bind
(
converse
));
}
.
bind
(
converse
));
}
.
bind
(
converse
,
mock
,
test_utils
));
}));
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