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
16d62bf9
Commit
16d62bf9
authored
Jul 11, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken tests due to using ES2015 promises
parent
e75b6ad6
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1103 additions
and
272 deletions
+1103
-272
spec/bookmarks.js
spec/bookmarks.js
+34
-11
spec/chatbox.js
spec/chatbox.js
+379
-92
spec/chatroom.js
spec/chatroom.js
+276
-52
spec/controlbox.js
spec/controlbox.js
+238
-52
spec/converse.js
spec/converse.js
+31
-25
spec/headline.js
spec/headline.js
+7
-2
spec/mam.js
spec/mam.js
+2
-3
spec/minchats.js
spec/minchats.js
+24
-4
spec/notification.js
spec/notification.js
+24
-4
spec/otr.js
spec/otr.js
+14
-5
spec/ping.js
spec/ping.js
+12
-2
spec/presence.js
spec/presence.js
+6
-1
spec/protocol.js
spec/protocol.js
+32
-6
spec/register.js
spec/register.js
+2
-3
spec/roomslist.js
spec/roomslist.js
+8
-4
spec/transcripts.js
spec/transcripts.js
+2
-2
spec/xmppstatus.js
spec/xmppstatus.js
+2
-3
tests/mock.js
tests/mock.js
+10
-1
No files found.
spec/bookmarks.js
View file @
16d62bf9
...
...
@@ -17,7 +17,9 @@
describe
(
"
A chat room
"
,
function
()
{
it
(
"
can be bookmarked
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
can be bookmarked
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
...
...
@@ -124,9 +126,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
// We ignore this IQ stanza... (unless it's an error stanza), so
// nothing to test for here.
done
();
}));
it
(
"
will be automatically opened if 'autojoin' is set on the bookmark
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
will be automatically opened if 'autojoin' is set on the bookmark
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
jid
=
'
lounge@localhost
'
;
_converse
.
bookmarks
.
create
({
'
jid
'
:
jid
,
...
...
@@ -144,11 +149,14 @@
'
nick
'
:
'
Othello
'
});
expect
(
_
.
isUndefined
(
_converse
.
chatboxviews
.
get
(
jid
))).
toBeFalsy
();
done
();
}));
describe
(
"
when bookmarked
"
,
function
()
{
it
(
"
displays that it's bookmarked through its bookmark icon
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
displays that it's bookmarked through its bookmark icon
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
var
$bookmark_icon
=
view
.
$
(
'
.icon-pushpin
'
);
...
...
@@ -157,9 +165,12 @@
expect
(
$bookmark_icon
.
hasClass
(
'
button-on
'
)).
toBeTruthy
();
view
.
model
.
set
(
'
bookmarked
'
,
false
);
expect
(
$bookmark_icon
.
hasClass
(
'
button-on
'
)).
toBeFalsy
();
done
();
}));
it
(
"
can be unbookmarked
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
can be unbookmarked
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
test_utils
.
openChatRoom
(
_converse
,
'
theplay
'
,
'
conference.shakespeare.lit
'
,
'
JC
'
);
...
...
@@ -216,6 +227,7 @@
"
</pubsub>
"
+
"
</iq>
"
);
done
();
}));
});
...
...
@@ -293,8 +305,9 @@
*/
}));
it
(
"
can be retrieved from the XMPP server
"
,
mock
.
initConverseWithConnectionSpies
([
'
send
'
],
function
(
_converse
)
{
it
(
"
can be retrieved from the XMPP server
"
,
mock
.
initConverseWithPromises
(
[
'
send
'
],
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
/* Client requests all items
* -------------------------
*
...
...
@@ -366,11 +379,14 @@
expect
(
_converse
.
bookmarks
.
models
.
length
).
toBe
(
2
);
expect
(
_converse
.
bookmarks
.
findWhere
({
'
jid
'
:
'
theplay@conference.shakespeare.lit
'
}).
get
(
'
autojoin
'
)).
toBe
(
true
);
expect
(
_converse
.
bookmarks
.
findWhere
({
'
jid
'
:
'
another@conference.shakespeare.lit
'
}).
get
(
'
autojoin
'
)).
toBe
(
false
);
done
();
}));
describe
(
"
The rooms panel
"
,
function
()
{
it
(
"
shows a list of bookmarks
"
,
mock
.
initConverseWithConnectionSpies
([
'
send
'
],
function
(
_converse
)
{
it
(
"
shows a list of bookmarks
"
,
mock
.
initConverseWithPromises
(
[
'
send
'
],
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
IQ_id
;
expect
(
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
var
stanza
=
call
.
args
[
0
];
...
...
@@ -415,10 +431,12 @@
}).
c
(
'
nick
'
).
t
(
'
JC
'
).
up
().
up
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
$
(
'
#chatrooms dl.bookmarks dd
'
).
length
).
toBe
(
3
);
done
();
}));
it
(
"
remembers the toggle state of the bookmarks list
"
,
mock
.
initConverseWithConnectionSpies
([
'
send
'
],
function
(
_converse
)
{
it
(
"
remembers the toggle state of the bookmarks list
"
,
mock
.
initConverseWithPromises
(
[
'
send
'
],
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
IQ_id
;
expect
(
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
var
stanza
=
call
.
args
[
0
];
...
...
@@ -462,15 +480,19 @@
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
_converse
.
OPENED
);
done
();
}));
});
});
describe
(
"
When hide_open_bookmarks is true and a bookmarked room is opened
"
,
function
()
{
it
(
"
can be closed
"
,
mock
.
initConverse
({
hide_open_bookmarks
:
true
},
function
(
_converse
)
{
test_utils
.
openControlBox
().
openRoomsPanel
(
_converse
);
it
(
"
can be closed
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
hide_open_bookmarks
:
true
},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
().
openRoomsPanel
(
_converse
);
// XXX Create bookmarks view here, otherwise we need to mock stanza
// traffic for it to get created.
_converse
.
bookmarksview
=
new
_converse
.
BookmarksView
(
...
...
@@ -502,6 +524,7 @@
view
.
close
();
room_els
=
_converse
.
bookmarksview
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
1
);
done
();
}));
});
}));
spec/chatbox.js
View file @
16d62bf9
This diff is collapsed.
Click to expand it.
spec/chatroom.js
View file @
16d62bf9
This diff is collapsed.
Click to expand it.
spec/controlbox.js
View file @
16d62bf9
This diff is collapsed.
Click to expand it.
spec/converse.js
View file @
16d62bf9
...
...
@@ -7,7 +7,6 @@
}
(
this
,
function
(
jasmine
,
converse
,
mock
,
test_utils
)
{
var
b64_sha1
=
converse
.
env
.
b64_sha1
;
var
_
=
converse
.
env
.
_
;
var
$
=
converse
.
env
.
jQuery
;
describe
(
"
Converse
"
,
function
()
{
...
...
@@ -272,7 +271,9 @@
describe
(
"
The
\"
chats
\"
API
"
,
function
()
{
it
(
"
has a method 'get' which returns a wrapped chat box
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
has a method 'get' which returns a wrapped chat box
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterInitialized
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
...
...
@@ -295,9 +296,13 @@
expect
(
_
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
model
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
list
[
1
].
model
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
));
done
();
}));
it
(
"
has a method 'open' which opens and returns a wrapped chat box
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
has a method 'open' which opens and returns a wrapped chat box
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
);
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
chatboxview
;
...
...
@@ -318,6 +323,7 @@
expect
(
_
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
model
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
list
[
1
].
model
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
));
done
();
}));
});
...
...
spec/headline.js
View file @
16d62bf9
...
...
@@ -40,7 +40,9 @@
utils
.
isHeadlineMessage
.
restore
();
}));
it
(
"
will open and display headline messages
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
will open and display headline messages
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
/* <message from='notify.example.com'
* to='romeo@im.example.com'
* type='headline'
...
...
@@ -74,9 +76,12 @@
expect
(
utils
.
isHeadlineMessage
.
called
).
toBeTruthy
();
expect
(
utils
.
isHeadlineMessage
.
returned
(
true
)).
toBeTruthy
();
utils
.
isHeadlineMessage
.
restore
();
// unwraps
done
();
}));
it
(
"
will not show a headline messages from a full JID if allow_non_roster_messaging is false
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
will not show a headline messages from a full JID if allow_non_roster_messaging is false
"
,
mock
.
initConverse
(
function
(
_converse
)
{
_converse
.
allow_non_roster_messaging
=
false
;
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
var
stanza
=
$msg
({
...
...
spec/mam.js
View file @
16d62bf9
(
function
(
root
,
factory
)
{
define
([
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
jasmine
,
mock
,
converse
,
test_utils
)
{
define
([
"
j
query.noconflict
"
,
"
j
asmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
$
,
jasmine
,
mock
,
converse
,
test_utils
)
{
"
use strict
"
;
var
_
=
converse
.
env
.
_
;
var
$
=
converse
.
env
.
jQuery
;
var
Strophe
=
converse
.
env
.
Strophe
;
var
$iq
=
converse
.
env
.
$iq
;
var
$msg
=
converse
.
env
.
$msg
;
...
...
spec/minchats.js
View file @
16d62bf9
...
...
@@ -6,7 +6,11 @@
describe
(
"
The Minimized Chats Widget
"
,
function
()
{
it
(
"
shows chats that have been minimized
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
shows chats that have been minimized
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
...
...
@@ -34,9 +38,14 @@
expect
(
_converse
.
minimized_chats
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
_converse
.
minimized_chats
.
keys
().
length
).
toBe
(
2
);
expect
(
_
.
includes
(
_converse
.
minimized_chats
.
keys
(),
contact_jid
)).
toBeTruthy
();
done
();
}));
it
(
"
can be toggled to hide or show minimized chats
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
can be toggled to hide or show minimized chats
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
...
...
@@ -56,9 +65,14 @@
_converse
.
minimized_chats
.
$
(
'
#toggle-minimized-chats
'
).
click
();
expect
(
_converse
.
minimized_chats
.
$
(
'
.minimized-chats-flyout
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
expect
(
_converse
.
minimized_chats
.
toggleview
.
model
.
get
(
'
collapsed
'
)).
toBeTruthy
();
done
();
}));
it
(
"
shows the number messages received to minimized chats
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
shows the number messages received to minimized chats
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
...
...
@@ -120,9 +134,14 @@
id
:
(
new
Date
()).
getTime
()
}).
c
(
'
inactive
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
());
expect
(
_converse
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
text
()).
toBe
((
i
).
toString
());
done
();
}));
it
(
"
shows the number messages received to minimized groupchats
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
shows the number messages received to minimized groupchats
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
room_jid
=
'
kitchen@conference.shakespeare.lit
'
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
fires
'
);
...
...
@@ -142,6 +161,7 @@
expect
(
_converse
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
_converse
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
text
()).
toBe
(
'
1
'
);
done
();
}));
});
}));
spec/notification.js
View file @
16d62bf9
...
...
@@ -12,7 +12,11 @@
describe
(
"
And the desktop is not focused
"
,
function
()
{
describe
(
"
an HTML5 Notification
"
,
function
()
{
it
(
"
is shown when a new private message is received
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
is shown when a new private message is received
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
// TODO: not yet testing show_desktop_notifications setting
test_utils
.
createContacts
(
_converse
,
'
current
'
);
spyOn
(
_converse
,
'
showMessageNotification
'
);
...
...
@@ -30,9 +34,14 @@
_converse
.
chatboxes
.
onMessage
(
msg
);
// This will emit 'message'
expect
(
_converse
.
areDesktopNotificationsEnabled
).
toHaveBeenCalled
();
expect
(
_converse
.
showMessageNotification
).
toHaveBeenCalled
();
done
();
}));
it
(
"
is shown when you are mentioned in a chat room
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
is shown when you are mentioned in a chat room
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
...
...
@@ -63,9 +72,14 @@
if
(
no_notification
)
{
delete
window
.
Notification
;
}
done
();
}));
it
(
"
is shown for headline messages
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
is shown for headline messages
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
spyOn
(
_converse
,
'
showMessageNotification
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
var
stanza
=
$msg
({
...
...
@@ -84,6 +98,7 @@
'
notify.example.com
'
)
).
toBeTruthy
();
expect
(
_converse
.
showMessageNotification
).
toHaveBeenCalled
();
done
();
}));
it
(
"
is not shown for full JID headline messages if allow_non_roster_messaging is false
"
,
mock
.
initConverse
(
function
(
_converse
)
{
...
...
@@ -137,7 +152,11 @@
describe
(
"
When play_sounds is set to true
"
,
function
()
{
describe
(
"
A notification sound
"
,
function
()
{
it
(
"
is played when the current user is mentioned in a chat room
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
is played when the current user is mentioned in a chat room
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
_converse
.
play_sounds
=
true
;
...
...
@@ -175,6 +194,7 @@
view
.
onChatRoomMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
done
();
}));
});
});
...
...
spec/otr.js
View file @
16d62bf9
(
function
(
root
,
factory
)
{
define
([
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
jasmine
,
mock
,
converse
,
test_utils
)
{
var
$
=
converse
.
env
.
jQuery
;
define
([
"
jquery.noconflict
"
,
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
$
,
jasmine
,
mock
,
converse
,
test_utils
)
{
var
Strophe
=
converse
.
env
.
Strophe
;
var
b64_sha1
=
converse
.
env
.
b64_sha1
;
return
describe
(
"
The OTR module
"
,
function
()
{
it
(
"
will add processing hints to sent out encrypted <message> stanzas
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
will add processing hints to sent out encrypted <message> stanzas
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
@@ -25,11 +28,16 @@
expect
(
$hints
.
get
(
1
).
tagName
).
toBe
(
'
no-permanent-store
'
);
expect
(
$hints
.
get
(
2
).
tagName
).
toBe
(
'
no-copy
'
);
chatview
.
model
.
set
(
'
otr_status
'
,
UNENCRYPTED
);
// Reset again to UNENCRYPTED
done
();
}));
describe
(
"
An OTR Chat Message
"
,
function
()
{
it
(
"
will not be carbon copied when it's sent out
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
will not be carbon copied when it's sent out
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
@@ -46,6 +54,7 @@
expect
(
$sent
.
find
(
'
private
'
).
length
).
toBe
(
1
);
expect
(
$sent
.
find
(
'
private
'
).
attr
(
'
xmlns
'
)).
toBe
(
'
urn:xmpp:carbons:2
'
);
chatbox
.
set
(
'
otr_status
'
,
0
);
// Reset again to UNENCRYPTED
done
();
}));
});
});
...
...
spec/ping.js
View file @
16d62bf9
...
...
@@ -6,20 +6,30 @@
describe
(
"
XMPP Ping
"
,
function
()
{
describe
(
"
Ping and pong handlers
"
,
function
()
{
it
(
"
are registered when _converse.js is connected
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
are registered when _converse.js is connected
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
spyOn
(
_converse
,
'
registerPingHandler
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
registerPongHandler
'
).
and
.
callThrough
();
_converse
.
emit
(
'
connected
'
);
expect
(
_converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
_converse
.
registerPongHandler
).
toHaveBeenCalled
();
done
();
}));
it
(
"
are registered when _converse.js reconnected
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
are registered when _converse.js reconnected
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
spyOn
(
_converse
,
'
registerPingHandler
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
registerPongHandler
'
).
and
.
callThrough
();
_converse
.
emit
(
'
reconnected
'
);
expect
(
_converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
_converse
.
registerPongHandler
).
toHaveBeenCalled
();
done
();
}));
});
...
...
spec/presence.js
View file @
16d62bf9
...
...
@@ -49,7 +49,11 @@
describe
(
"
A received presence stanza
"
,
function
()
{
it
(
"
has its priority taken into account
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
has its priority taken into account
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Create some contacts so that we can test positioning
var
contact_jid
=
mock
.
cur_names
[
8
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -218,6 +222,7 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
[
0
]));
expect
(
_converse
.
roster
.
get
(
contact_jid
).
get
(
'
chat_status
'
)).
toBe
(
'
offline
'
);
expect
(
_
.
keys
(
contact
.
get
(
'
resources
'
)).
length
).
toBe
(
0
);
done
();
}));
});
}));
...
...
spec/protocol.js
View file @
16d62bf9
...
...
@@ -10,6 +10,7 @@
var
Strophe
=
converse
.
env
.
Strophe
;
var
$iq
=
converse
.
env
.
$iq
;
var
$pres
=
converse
.
env
.
$pres
;
var
_
=
converse
.
env
.
_
;
// See:
// https://xmpp.org/rfcs/rfc3921.html
...
...
@@ -47,11 +48,15 @@
* that session. A client MUST acknowledge each roster push with an IQ
* stanza of type "result".
*/
it
(
"
Subscribe to contact, contact accepts and subscribes back
"
,
mock
.
initConverseWithAsync
(
function
(
done
,
_converse
)
{
it
(
"
Subscribe to contact, contact accepts and subscribes back
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
roster_groups
:
false
},
function
(
done
,
_converse
)
{
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
_converse
.
roster_groups
=
false
;
var
contact
,
stanza
,
sent_stanza
,
IQ_id
;
test_utils
.
openControlBox
(
_converse
);
var
panel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
contactspanel
;
...
...
@@ -134,8 +139,10 @@
* </iq>
*/
var
create
=
_converse
.
roster
.
create
;
var
sent_stanzas
=
[];
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
function
(
stanza
)
{
sent_stanza
=
stanza
;
sent_stanzas
.
push
(
stanza
.
toLocaleString
());
});
spyOn
(
_converse
.
roster
,
'
create
'
).
and
.
callFake
(
function
()
{
contact
=
create
.
apply
(
_converse
.
roster
,
arguments
);
...
...
@@ -165,6 +172,11 @@
*
* <presence to='contact@example.org' type='subscribe'/>
*/
test_utils
.
waitUntil
(
function
()
{
return
sent_stanzas
.
length
==
1
;
}).
then
(
function
()
{
expect
(
contact
.
subscribe
).
toHaveBeenCalled
();
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
// Strophe adds the xmlns attr (although not in spec)
"
<presence to='contact@example.org' type='subscribe' xmlns='jabber:client'>
"
+
...
...
@@ -347,9 +359,14 @@
expect
(
$contacts
.
hasClass
(
'
both
'
)).
toBeTruthy
();
done
();
});
});
}));
it
(
"
Alternate Flow: Contact Declines Subscription Request
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
Alternate Flow: Contact Declines Subscription Request
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
...
...
@@ -429,11 +446,16 @@
"
</query>
"
+
"
</iq>
"
);
done
();
}));
it
(
"
Unsubscribe to a contact when subscription is mutual
"
,
mock
.
initConverseWithAsync
(
function
(
done
,
_converse
)
{
it
(
"
Unsubscribe to a contact when subscription is mutual
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
roster_groups
:
false
},
function
(
done
,
_converse
)
{
var
sent_IQ
,
IQ_id
,
jid
=
'
annegreet.gomez@localhost
'
;
_converse
.
roster_groups
=
false
;
test_utils
.
openControlBox
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
...
...
@@ -490,7 +512,10 @@
});
}));
it
(
"
Receiving a subscription request
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
Receiving a subscription request
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Create some contacts so that we can test positioning
spyOn
(
_converse
,
"
emit
"
);
...
...
@@ -516,6 +541,7 @@
expect
(
$header
.
is
(
"
:visible
"
)).
toBeTruthy
();
var
$contacts
=
$header
.
parent
().
nextUntil
(
'
dt
'
,
'
dd
'
);
expect
(
$contacts
.
length
).
toBe
(
1
);
done
();
});
}));
});
...
...
spec/register.js
View file @
16d62bf9
(
function
(
root
,
factory
)
{
define
([
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
jasmine
,
mock
,
converse
,
test_utils
)
{
var
$
=
converse
.
env
.
jQuery
;
define
([
"
jquery.noconflict
"
,
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
$
,
jasmine
,
mock
,
converse
,
test_utils
)
{
var
Strophe
=
converse
.
env
.
Strophe
;
var
$iq
=
converse
.
env
.
$iq
;
...
...
spec/roomslist.js
View file @
16d62bf9
...
...
@@ -7,12 +7,13 @@
describe
(
"
The converse-roomslist plugin
"
,
function
()
{
it
(
"
is shown under a list of open rooms in the
\"
Rooms
\"
panel
"
,
mock
.
initConverse
(
it
(
"
is shown under a list of open rooms in the
\"
Rooms
\"
panel
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function
(
_converse
)
{
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
().
openRoomsPanel
(
_converse
);
var
controlbox
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
...
...
@@ -46,18 +47,20 @@
list
=
controlbox
.
el
.
querySelector
(
'
div.rooms-list-container
'
);
expect
(
_
.
includes
(
list
.
classList
,
'
hidden
'
)).
toBeTruthy
();
done
();
}
));
});
describe
(
"
An room shown in the rooms list
"
,
function
()
{
it
(
"
can be closed
"
,
mock
.
initConverse
(
it
(
"
can be closed
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function
(
_converse
)
{
function
(
done
,
_converse
)
{
spyOn
(
window
,
'
confirm
'
).
and
.
callFake
(
function
()
{
return
true
;
...
...
@@ -76,6 +79,7 @@
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
0
);
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
done
();
}));
it
(
"
shows unread messages directed at the user
"
,
mock
.
initConverseWithAsync
(
...
...
spec/transcripts.js
View file @
16d62bf9
(
function
(
root
,
factory
)
{
define
([
"
jquery.noconflict
"
,
"
converse-core
"
,
"
mock
"
,
"
test_utils
"
,
...
...
@@ -7,10 +8,9 @@
"
transcripts
"
],
factory
);
}
(
this
,
function
(
converse
,
mock
,
test_utils
,
utils
,
transcripts
)
{
}
(
this
,
function
(
$
,
converse
,
mock
,
test_utils
,
utils
,
transcripts
)
{
var
Strophe
=
converse
.
env
.
Strophe
;
var
_
=
converse
.
env
.
_
;
var
$
=
converse
.
env
.
jQuery
;
var
IGNORED_TAGS
=
[
'
stream:features
'
,
'
auth
'
,
...
...
spec/xmppstatus.js
View file @
16d62bf9
(
function
(
root
,
factory
)
{
define
([
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
jasmine
,
mock
,
converse
,
test_utils
)
{
var
$
=
converse
.
env
.
jQuery
;
define
([
"
jquery.noconflict
"
,
"
jasmine
"
,
"
mock
"
,
"
converse-core
"
,
"
test-utils
"
],
factory
);
}
(
this
,
function
(
$
,
jasmine
,
mock
,
converse
,
test_utils
)
{
return
describe
(
"
The XMPPStatus model
"
,
function
()
{
...
...
tests/mock.js
View file @
16d62bf9
...
...
@@ -2,6 +2,7 @@
define
(
"
mock
"
,
[
'
jquery.noconflict
'
,
'
converse
'
],
factory
);
}(
this
,
function
(
$
,
converse_api
)
{
var
_
=
converse_api
.
env
.
_
;
var
Promise
=
converse_api
.
env
.
Promise
;
var
Strophe
=
converse_api
.
env
.
Strophe
;
var
$iq
=
converse_api
.
env
.
$iq
;
var
mock
=
{};
...
...
@@ -76,7 +77,7 @@
};
}();
function
initConverse
(
settings
,
spies
)
{
function
initConverse
(
settings
,
spies
,
promises
)
{
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
...
...
@@ -105,6 +106,14 @@
return
converse
;
}
mock
.
initConverseWithPromises
=
function
(
spies
,
promise_names
,
settings
,
func
)
{
return
function
(
done
)
{
var
_converse
=
initConverse
(
settings
,
spies
);
var
promises
=
_
.
map
(
promise_names
,
_converse
.
api
.
waitUntil
);
Promise
.
all
(
promises
).
then
(
_
.
partial
(
func
,
done
,
_converse
));
}
};
mock
.
initConverseWithConnectionSpies
=
function
(
spies
,
settings
,
func
)
{
if
(
_
.
isFunction
(
settings
))
{
var
_func
=
settings
;
...
...
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