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