Commit e22923d5 authored by JC Brand's avatar JC Brand

Fix failing test

parent 530e2981
...@@ -239,14 +239,24 @@ ...@@ -239,14 +239,24 @@
})); }));
it("has a method 'add' with which contacts can be added", it("has a method 'add' with which contacts can be added",
mock.initConverse(['rosterInitialized'], {}, (done, _converse) => { mock.initConverse(['rosterInitialized'], {}, async (done, _converse) => {
test_utils.createContacts(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current', 0);
const error = new TypeError('contacts.add: invalid jid'); try {
expect(_converse.api.contacts.add).toThrow(error); await _converse.api.contacts.add();
expect(_converse.api.contacts.add.bind(_converse.api, "invalid jid")).toThrow(error); throw new Error('Call should have failed');
} catch (e) {
expect(e.message).toBe('contacts.add: invalid jid');
}
try {
await _converse.api.contacts.add("invalid jid");
throw new Error('Call should have failed');
} catch (e) {
expect(e.message).toBe('contacts.add: invalid jid');
}
spyOn(_converse.roster, 'addAndSubscribe'); spyOn(_converse.roster, 'addAndSubscribe');
_converse.api.contacts.add("newcontact@example.org"); await _converse.api.contacts.add("newcontact@example.org");
expect(_converse.roster.addAndSubscribe).toHaveBeenCalled(); expect(_converse.roster.addAndSubscribe).toHaveBeenCalled();
done(); done();
})); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment