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
6253dd52
Commit
6253dd52
authored
Oct 11, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: let logout return a promise and wait for it in tests
parent
a0bd6dba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
src/headless/converse-core.js
src/headless/converse-core.js
+16
-7
tests/mock.js
tests/mock.js
+4
-2
No files found.
src/headless/converse-core.js
View file @
6253dd52
...
...
@@ -1552,17 +1552,26 @@ _converse.api = {
* @example _converse.api.user.logout();
*/
logout
()
{
const
promise
=
u
.
getResolveablePromise
();
const
complete
=
()
=>
{
// Recreate all the promises
Object
.
keys
(
_converse
.
promises
).
forEach
(
addPromise
);
/**
* Triggered once the user has logged out.
* @event _converse#logout
*/
_converse
.
api
.
trigger
(
'
logout
'
);
promise
.
resolve
();
}
_converse
.
setDisconnectionCause
(
_converse
.
LOGOUT
,
undefined
,
true
);
if
(
_converse
.
connection
!==
undefined
)
{
_converse
.
api
.
listen
.
once
(
'
disconnected
'
,
()
=>
complete
());
_converse
.
connection
.
disconnect
();
}
else
{
complete
();
}
// Recreate all the promises
Object
.
keys
(
_converse
.
promises
).
forEach
(
addPromise
);
/**
* Triggered once the user has logged out.
* @event _converse#logout
*/
_converse
.
api
.
trigger
(
'
logout
'
);
return
promise
;
},
/**
...
...
tests/mock.js
View file @
6253dd52
...
...
@@ -262,8 +262,10 @@
}
return
async
done
=>
{
const
_converse
=
await
initConverse
(
settings
,
spies
);
function
_done
()
{
_converse
.
api
.
user
.
logout
();
async
function
_done
()
{
await
_converse
.
api
.
user
.
logout
();
const
el
=
document
.
querySelector
(
'
#conversejs
'
);
el
.
parentElement
.
removeChild
(
el
);
done
();
}
await
Promise
.
all
((
promise_names
||
[]).
map
(
_converse
.
api
.
waitUntil
));
...
...
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