Commit 0e81234f authored by JC Brand's avatar JC Brand

Fix failing tests

parent 22bdccc7
...@@ -141,11 +141,15 @@ ...@@ -141,11 +141,15 @@
await test_utils.waitUntil(() => u.isVisible(modal.el), 1000); await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
const view = _converse.xmppstatusview; const view = _converse.xmppstatusview;
spyOn(_converse.api, "trigger");
modal.el.querySelector('label[for="radio-busy"]').click(); // Change status to "dnd" modal.el.querySelector('label[for="radio-busy"]').click(); // Change status to "dnd"
modal.el.querySelector('[type="submit"]').click(); modal.el.querySelector('[type="submit"]').click();
const last_stanza = _converse.connection.sent_stanzas.pop();
expect(_converse.api.trigger).toHaveBeenCalledWith('statusChanged', 'dnd'); expect(Strophe.serialize(last_stanza)).toBe(
`<presence xmlns="jabber:client">`+
`<show>dnd</show>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`);
const first_child = view.el.querySelector('.xmpp-status span:first-child'); const first_child = view.el.querySelector('.xmpp-status span:first-child');
expect(u.hasClass('online', first_child)).toBe(false); expect(u.hasClass('online', first_child)).toBe(false);
expect(u.hasClass('dnd', first_child)).toBe(true); expect(u.hasClass('dnd', first_child)).toBe(true);
...@@ -166,13 +170,17 @@ ...@@ -166,13 +170,17 @@
await test_utils.waitUntil(() => u.isVisible(modal.el), 1000); await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
const view = _converse.xmppstatusview; const view = _converse.xmppstatusview;
spyOn(_converse.api, "trigger");
const msg = 'I am happy'; const msg = 'I am happy';
modal.el.querySelector('input[name="status_message"]').value = msg; modal.el.querySelector('input[name="status_message"]').value = msg;
modal.el.querySelector('[type="submit"]').click(); modal.el.querySelector('[type="submit"]').click();
const last_stanza = _converse.connection.sent_stanzas.pop();
expect(Strophe.serialize(last_stanza)).toBe(
`<presence xmlns="jabber:client">`+
`<status>I am happy</status>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`);
expect(_converse.api.trigger).toHaveBeenCalledWith('statusMessageChanged', msg);
const first_child = view.el.querySelector('.xmpp-status span:first-child'); const first_child = view.el.querySelector('.xmpp-status span:first-child');
expect(u.hasClass('online', first_child)).toBe(true); expect(u.hasClass('online', first_child)).toBe(true);
expect(view.el.querySelector('.xmpp-status span:first-child').textContent.trim()).toBe(msg); expect(view.el.querySelector('.xmpp-status span:first-child').textContent.trim()).toBe(msg);
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
_converse.api.connection.reconnect(); _converse.api.connection.reconnect();
stanza = await test_utils.waitUntil(() => stanza = await test_utils.waitUntil(() =>
sent_stanzas.filter(s => (s.tagName === 'resume')).pop()); sent_stanzas.filter(s => (s.tagName === 'resume')).pop());
expect(Strophe.serialize(stanza)).toEqual('<resume h="2" previd="some-long-sm-id" xmlns="urn:xmpp:sm:3"/>'); expect(Strophe.serialize(stanza)).toEqual('<resume h="1" previd="some-long-sm-id" xmlns="urn:xmpp:sm:3"/>');
result = u.toStanza(`<resumed xmlns="urn:xmpp:sm:3" h="another-sequence-number" previd="some-long-sm-id"/>`); result = u.toStanza(`<resumed xmlns="urn:xmpp:sm:3" h="another-sequence-number" previd="some-long-sm-id"/>`);
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
......
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