Commit 77734d5f authored by JC Brand's avatar JC Brand

Improve test to also check stanza traffic

parent b8765008
......@@ -613,18 +613,26 @@
fullname: name
});
spyOn(window, 'confirm').and.returnValue(true);
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback) {
if (typeof callback === "function") { return callback(); }
});
await test_utils.waitUntil(() => {
const el = _converse.rosterview.get('Pending contacts').el;
return u.isVisible(el) && _.filter(el.querySelectorAll('li'), li => u.isVisible(li)).length;
}, 700)
spyOn(_converse.connection, 'sendIQ').and.callThrough();
sizzle(`.remove-xmpp-contact[title="Click to remove ${name} as a contact"]`, _converse.rosterview.el).pop().click();
expect(window.confirm).toHaveBeenCalled();
expect(_converse.connection.sendIQ).toHaveBeenCalled();
const iq = _converse.connection.IQ_stanzas.pop();
expect(Strophe.serialize(iq)).toBe(
`<iq id="${iq.getAttribute('id')}" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:roster">`+
`<item jid="suleyman.van.beusichem@localhost" subscription="remove"/>`+
`</query>`+
`</iq>`);
const stanza = u.toStanza(`<iq id="${iq.getAttribute('id')}" to="dummy@localhost/resource" type="result"/>`);
_converse.connection._dataRecv(test_utils.createRequest(stanza));
await test_utils.waitUntil(() => !u.isVisible(_converse.rosterview.get('Pending contacts').el));
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