Przeglądaj źródła

Fix failing tests

JC Brand 6 lat temu
rodzic
commit
0e81234f73
2 zmienionych plików z 15 dodań i 7 usunięć
  1. 14 6
      spec/controlbox.js
  2. 1 1
      spec/smacks.js

+ 14 - 6
spec/controlbox.js

@@ -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();
-
-                expect(_converse.api.trigger).toHaveBeenCalledWith('statusChanged', 'dnd');
+                const last_stanza = _converse.connection.sent_stanzas.pop();
+                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 @@
 
 
                 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);

+ 1 - 1
spec/smacks.js

@@ -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));