Fix failing test and use async/await
This commit is contained in:
parent
affafc746c
commit
9e33279fc2
@ -1187,29 +1187,24 @@
|
|||||||
it("can have their requests accepted by the user",
|
it("can have their requests accepted by the user",
|
||||||
mock.initConverseWithPromises(
|
mock.initConverseWithPromises(
|
||||||
null, ['rosterGroupsFetched'], {},
|
null, ['rosterGroupsFetched'], {},
|
||||||
function (done, _converse) {
|
async function (done, _converse) {
|
||||||
|
|
||||||
test_utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
test_utils.createContacts(_converse, 'requesting').openControlBox();
|
test_utils.createContacts(_converse, 'requesting').openControlBox();
|
||||||
test_utils.waitUntil(function () {
|
await test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group li').length)
|
||||||
return $(_converse.rosterview.el).find('.roster-group li').length;
|
|
||||||
}, 700).then(function () {
|
|
||||||
// TODO: Testing can be more thorough here, the user is
|
// TODO: Testing can be more thorough here, the user is
|
||||||
// actually not accepted/authorized because of
|
// actually not accepted/authorized because of
|
||||||
// mock_connection.
|
// mock_connection.
|
||||||
var name = mock.req_names.sort()[0];
|
const jid = mock.req_names.sort()[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
var jid = name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
const contact = _converse.roster.get(jid);
|
||||||
var contact = _converse.roster.get(jid);
|
spyOn(contact, 'authorize').and.callFake(() => contact);
|
||||||
spyOn(_converse.roster, 'sendContactAddIQ').and.callFake(function (jid, fullname, groups, callback) {
|
spyOn(_converse.roster, 'sendContactAddIQ').and.callFake(() => Promise.resolve());
|
||||||
callback();
|
|
||||||
});
|
|
||||||
spyOn(contact, 'authorize').and.callFake(function () { return contact; });
|
|
||||||
$(_converse.rosterview.el).find(".req-contact-name:contains('"+name+"')")
|
$(_converse.rosterview.el).find(".req-contact-name:contains('"+name+"')")
|
||||||
.parent().parent().find('.accept-xmpp-request')[0].click();
|
.parent().parent().find('.accept-xmpp-request')[0].click();
|
||||||
expect(_converse.roster.sendContactAddIQ).toHaveBeenCalled();
|
expect(_converse.roster.sendContactAddIQ).toHaveBeenCalled();
|
||||||
|
await test_utils.waitUntil(() => contact.authorize.calls.count());
|
||||||
expect(contact.authorize).toHaveBeenCalled();
|
expect(contact.authorize).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("can have their requests denied by the user",
|
it("can have their requests denied by the user",
|
||||||
|
Loading…
Reference in New Issue
Block a user