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
a8ed46f6
Commit
a8ed46f6
authored
Dec 12, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await in spec
parent
df3118fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
65 deletions
+56
-65
dist/converse.js
dist/converse.js
+1
-2
spec/user-details-modal.js
spec/user-details-modal.js
+55
-63
No files found.
dist/converse.js
View file @
a8ed46f6
...
@@ -42758,7 +42758,6 @@ Strophe.Websocket.prototype = {
...
@@ -42758,7 +42758,6 @@ Strophe.Websocket.prototype = {
});
});
//# sourceMappingURL=strophe.js.map
//# sourceMappingURL=strophe.js.map
/***/ }),
/***/ }),
/***/ "./node_modules/strophejs-plugin-ping/strophe.ping.js":
/***/ "./node_modules/strophejs-plugin-ping/strophe.ping.js":
...
@@ -94190,7 +94189,7 @@ __p += '\n<a class="list-item-action fa ';
...
@@ -94190,7 +94189,7 @@ __p += '\n<a class="list-item-action fa ';
if (o.bookmarked) { ;
if (o.bookmarked) { ;
__p += ' fa-bookmark remove-bookmark button-on ';
__p += ' fa-bookmark remove-bookmark button-on ';
} else { ;
} else { ;
__p += ' add-bookmark fa-bookmark
-o
';
__p += ' add-bookmark fa-bookmark ';
} ;
} ;
__p += '"\n data-room-jid="' +
__p += '"\n data-room-jid="' +
__e(o.jid) +
__e(o.jid) +
spec/user-details-modal.js
View file @
a8ed46f6
...
@@ -17,85 +17,77 @@
...
@@ -17,85 +17,77 @@
it
(
"
can be used to remove a contact
"
,
it
(
"
can be used to remove a contact
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
let
view
,
show_modal_button
,
modal
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
let
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
show_modal_button
.
click
();
show_modal_button
.
click
();
modal
=
view
.
user_details_modal
;
const
modal
=
view
.
user_details_modal
;
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
}).
then
(
function
()
{
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
)
{
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
)
{
callback
();
callback
();
});
});
let
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
remove_contact_button
.
click
();
remove_contact_button
.
click
();
await
test_utils
.
waitUntil
(()
=>
modal
.
el
.
getAttribute
(
'
aria-hidden
'
),
1000
);
return
test_utils
.
waitUntil
(()
=>
modal
.
el
.
getAttribute
(
'
aria-hidden
'
),
1000
);
}).
then
(
function
()
{
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
.
click
();
show_modal_button
.
click
();
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
_
.
isNull
(
remove_contact_button
)).
toBeTruthy
();
expect
(
_
.
isNull
(
remove_contact_button
)).
toBeTruthy
();
done
();
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
}));
it
(
"
shows an alert when an error happened while removing the contact
"
,
it
(
"
shows an alert when an error happened while removing the contact
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
let
view
,
modal
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
.
then
(()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
let
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
show_modal_button
.
click
();
show_modal_button
.
click
();
const
modal
=
view
.
user_details_modal
;
modal
=
view
.
user_details_modal
;
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
);
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
}).
then
(
function
()
{
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
,
errback
)
{
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
errback
();
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
,
errback
)
{
});
errback
();
let
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
});
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
remove_contact_button
.
click
();
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
document
.
querySelector
(
'
.alert-danger
'
)),
2000
);
remove_contact_button
.
click
();
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
document
.
querySelector
(
'
.alert-danger
'
)),
2000
);
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
}).
then
(
function
()
{
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
.
toBe
(
"
Sorry, there was an error while trying to remove Max Frankfurter as a contact.
"
);
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
document
.
querySelector
(
'
.alert-danger button.close
'
).
click
();
.
toBe
(
"
Sorry, there was an error while trying to remove Max Frankfurter as a contact.
"
);
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
document
.
querySelector
(
'
.alert-danger button.close
'
).
click
();
show_modal_button
.
click
();
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
show_modal_button
.
click
();
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
}).
then
(
function
()
{
show_modal_button
.
click
();
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
show_modal_button
.
click
();
const
modal
=
view
.
user_details_modal
;
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
}).
then
(
function
()
{
done
();
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
}));
});
});
}));
}));
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