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
c22fe41a
Commit
c22fe41a
authored
Nov 22, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await in tests
parent
cb3ba7bd
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
447 additions
and
474 deletions
+447
-474
spec/bookmarks.js
spec/bookmarks.js
+313
-325
spec/converse.js
spec/converse.js
+55
-55
spec/roomslist.js
spec/roomslist.js
+79
-94
No files found.
spec/bookmarks.js
View file @
c22fe41a
This diff is collapsed.
Click to expand it.
spec/converse.js
View file @
c22fe41a
...
...
@@ -11,9 +11,10 @@
describe
(
"
Converse
"
,
function
()
{
describe
(
"
Authentication
"
,
function
()
{
it
(
"
needs either a bosh_service_url a websocket_url or both
"
,
mock
.
initConverse
(
function
(
_converse
)
{
var
url
=
_converse
.
bosh_service_url
;
var
connection
=
_converse
.
connection
;
const
url
=
_converse
.
bosh_service_url
;
const
connection
=
_converse
.
connection
;
delete
_converse
.
bosh_service_url
;
delete
_converse
.
connection
;
expect
(
_converse
.
initConnection
).
toThrow
(
...
...
@@ -271,44 +272,45 @@
describe
(
"
The
\"
chats
\"
API
"
,
function
()
{
it
(
"
has a method 'get' which returns the promise that resolves to a chat model
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterInitialized
'
,
'
chatBoxesInitialized
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
// Test on chat that's not open
let
box
=
_converse
.
api
.
chats
.
get
(
jid
);
expect
(
typeof
box
===
'
undefined
'
).
toBeTruthy
();
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
// Test for one JID
test_utils
.
openChatBoxFor
(
_converse
,
jid
);
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
1
).
then
(()
=>
{
box
=
_converse
.
api
.
chats
.
get
(
jid
);
expect
(
box
instanceof
Object
).
toBeTruthy
(
);
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
)
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
expect
(
u
.
isVisible
(
chatboxview
.
el
)).
toBeTruthy
();
// Test for multiple JIDs
test_utils
.
openChatBoxFor
(
_converse
,
jid2
);
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
2
);
}).
then
(()
=>
{
const
list
=
_converse
.
api
.
chats
.
get
([
jid
,
jid2
]
);
expect
(
_
.
isArray
(
list
)).
toBeTruthy
(
);
expect
(
list
[
0
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
)
);
expect
(
list
[
1
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
));
done
(
);
}).
catch
(
_
.
partial
(
console
.
error
,
_
)
);
null
,
[
'
rosterInitialized
'
,
'
chatBoxesInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
(
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
()
;
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
// Test on chat that's not open
let
box
=
_converse
.
api
.
chats
.
get
(
jid
);
expect
(
typeof
box
===
'
undefined
'
).
toBeTruthy
();
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
// Test for one JID
test_utils
.
openChatBoxFor
(
_converse
,
jid
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
1
);
box
=
_converse
.
api
.
chats
.
get
(
jid
);
expect
(
box
instanceof
Object
).
toBeTruthy
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
)
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
expect
(
u
.
isVisible
(
chatboxview
.
el
)).
toBeTruthy
(
);
// Test for multiple JIDs
test_utils
.
openChatBoxFor
(
_converse
,
jid2
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
2
);
const
list
=
_converse
.
api
.
chats
.
get
([
jid
,
jid2
]
);
expect
(
_
.
isArray
(
list
)).
toBeTruthy
(
);
expect
(
list
[
0
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
list
[
1
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
)
);
done
(
);
}));
it
(
"
has a method 'open' which opens and returns a promise that resolves to a chat model
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesInitialized
'
],
{},
function
(
done
,
_converse
)
{
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
...
...
@@ -319,23 +321,21 @@
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
return
_converse
.
api
.
chats
.
open
(
jid
).
then
((
box
)
=>
{
expect
(
box
instanceof
Object
).
toBeTruthy
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
_
.
keys
(
box
),
[
'
close
'
,
'
endOTR
'
,
'
focus
'
,
'
get
'
,
'
initiateOTR
'
,
'
is_chatroom
'
,
'
maximize
'
,
'
minimize
'
,
'
open
'
,
'
set
'
]
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
expect
(
u
.
isVisible
(
chatboxview
.
el
)).
toBeTruthy
();
// Test for multiple JIDs
return
_converse
.
api
.
chats
.
open
([
jid
,
jid2
]);
}).
then
((
list
)
=>
{
expect
(
_
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
list
[
1
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
));
done
();
});
const
box
=
await
_converse
.
api
.
chats
.
open
(
jid
);
expect
(
box
instanceof
Object
).
toBeTruthy
();
expect
(
box
.
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
_
.
keys
(
box
),
[
'
close
'
,
'
endOTR
'
,
'
focus
'
,
'
get
'
,
'
initiateOTR
'
,
'
is_chatroom
'
,
'
maximize
'
,
'
minimize
'
,
'
open
'
,
'
set
'
]
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
expect
(
u
.
isVisible
(
chatboxview
.
el
)).
toBeTruthy
();
// Test for multiple JIDs
const
list
=
await
_converse
.
api
.
chats
.
open
([
jid
,
jid2
]);
expect
(
_
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid
));
expect
(
list
[
1
].
get
(
'
box_id
'
)).
toBe
(
b64_sha1
(
jid2
));
done
();
}));
});
...
...
@@ -361,7 +361,7 @@
it
(
"
only has a method 'add' for registering plugins
"
,
mock
.
initConverse
(
function
(
_converse
)
{
expect
(
_
.
keys
(
converse
.
plugins
)).
toEqual
([
"
add
"
]);
// Cheating a little bit. We clear the plugins to test more easily.
var
_old_plugins
=
_converse
.
pluggable
.
plugins
;
const
_old_plugins
=
_converse
.
pluggable
.
plugins
;
_converse
.
pluggable
.
plugins
=
[];
converse
.
plugins
.
add
(
'
plugin1
'
,
{});
expect
(
_
.
keys
(
_converse
.
pluggable
.
plugins
)).
toEqual
([
'
plugin1
'
]);
...
...
spec/roomslist.js
View file @
c22fe41a
This diff is collapsed.
Click to expand it.
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