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
6aed4381
Commit
6aed4381
authored
Apr 18, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add XMPP Status Widget tests
parent
3be0f2d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
16 deletions
+41
-16
converse.js
converse.js
+1
-4
spec/MainSpec.js
spec/MainSpec.js
+40
-12
No files found.
converse.js
View file @
6aed4381
/*!
* Converse.js (XMPP-based instant messaging with Strophe.js and backbone.js)
* http://
opkode.com
* http://
conversejs.org
*
* Copyright (c) 2012 Jan-Carel Brand (jc@opkode.com)
* Dual licensed under the MIT and GPL Licenses
*/
/* The following line defines global variables defined elsewhere. */
/*globals jQuery, portal_url*/
// AMD/global registrations
(
function
(
root
,
factory
)
{
if
(
console
===
undefined
||
console
.
log
===
undefined
)
{
...
...
spec/MainSpec.js
View file @
6aed4381
...
...
@@ -52,15 +52,7 @@
};
// Clear localStorage
window
.
localStorage
.
removeItem
(
hex_sha1
(
'
converse.rosteritems-
'
+
this
.
bare_jid
));
window
.
localStorage
.
removeItem
(
hex_sha1
(
'
converse.chatboxes-
'
+
this
.
bare_jid
));
window
.
localStorage
.
removeItem
(
hex_sha1
(
'
converse.xmppstatus-
'
+
this
.
bare_jid
));
window
.
localStorage
.
removeItem
(
hex_sha1
(
'
converse.messages
'
+
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
));
window
.
localStorage
.
clear
();
this
.
prebind
=
true
;
this
.
onConnected
(
mock_connection
);
this
.
animate
=
false
;
// don't use animations
...
...
@@ -78,11 +70,47 @@
describe
(
"
The Status Widget
"
,
$
.
proxy
(
function
()
{
it
(
"
can be used to set the current user's chat status
"
,
$
.
proxy
(
function
()
{
// TODO
var
view
=
this
.
xmppstatusview
;
spyOn
(
view
,
'
toggleOptions
'
).
andCallThrough
();
spyOn
(
view
,
'
setStatus
'
).
andCallThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
click
();
expect
(
view
.
toggleOptions
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
hasClass
(
'
online
'
)).
toBe
(
false
);
runs
(
function
()
{
spyOn
(
view
,
'
updateStatusUI
'
).
andCallThrough
();
view
.
initialize
();
// Rebind events for spy
view
.
$el
.
find
(
'
.dropdown dd ul li a
'
).
first
().
click
();
expect
(
view
.
setStatus
).
toHaveBeenCalled
();
});
waits
(
100
);
runs
(
$
.
proxy
(
function
()
{
expect
(
view
.
updateStatusUI
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
hasClass
(
'
online
'
)).
toBe
(
true
);
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status span.value
'
).
text
()).
toBe
(
'
I am online
'
);
},
xmppchat
));
},
xmppchat
));
it
(
"
can be used to set a custom status message
"
,
$
.
proxy
(
function
()
{
// TODO
var
view
=
this
.
xmppstatusview
;
spyOn
(
view
,
'
setStatusMessage
'
).
andCallThrough
();
spyOn
(
view
,
'
renderStatusChangeForm
'
).
andCallThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
runs
(
function
()
{
view
.
$el
.
find
(
'
a.change-xmpp-status-message
'
).
click
();
expect
(
view
.
renderStatusChangeForm
).
toHaveBeenCalled
();
});
waits
(
250
);
runs
(
function
()
{
var
msg
=
'
I am happy
'
;
view
.
$el
.
find
(
'
form input.custom-xmpp-status
'
).
val
(
msg
);
view
.
$el
.
find
(
'
form#set-custom-xmpp-status
'
).
submit
();
expect
(
view
.
setStatusMessage
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
hasClass
(
'
online
'
)).
toBe
(
true
);
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status span.value
'
).
text
()).
toBe
(
msg
);
});
},
xmppchat
));
},
xmppchat
));
...
...
@@ -477,7 +505,7 @@
it
(
"
can be sent from a chatbox, and will appear inside it
"
,
$
.
proxy
(
function
()
{
var
contact_jid
=
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
chatboxesview
.
views
[
contact_jid
];
var
message
=
'
This
is a message sent from the
chatbox
'
;
var
message
=
'
This
message is sent from this
chatbox
'
;
spyOn
(
view
,
'
sendMessage
'
).
andCallThrough
();
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
message
);
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
...
...
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