Commit 9bc8bdf3 authored by JC Brand's avatar JC Brand

Test updates after updating to use latest strophe.js

`toLocaleString` now returns element attributes in alphabetical order
(for better cross-browser consistency).

Also, `toLocaleString` is now used in favor of `outerHTML` because
browsers aren't consistent with one another in their output.
parent 79b8ed71
This diff is collapsed.
...@@ -14089,9 +14089,7 @@ ...@@ -14089,9 +14089,7 @@
"dev": true "dev": true
}, },
"strophe.js": { "strophe.js": {
"version": "1.2.16", "version": "github:strophe/strophejs#a2692dcfdaf7d591254ac73f3d8584992b6f8da7",
"resolved": "https://registry.npmjs.org/strophe.js/-/strophe.js-1.2.16.tgz",
"integrity": "sha512-r/Uq7aqrusg25Y0qHwV48cFnMY6K/CuZdGt3EggRx3kY4sMv8lG+AFoMlrmTcYVMG1BaJvQfv9Cthw4Ll8z7fQ==",
"dev": true "dev": true
}, },
"strophejs-plugin-ping": { "strophejs-plugin-ping": {
...@@ -14100,7 +14098,7 @@ ...@@ -14100,7 +14098,7 @@
"integrity": "sha1-NXEmxTZZSwZmjhh4c4Ey+sNciJY=", "integrity": "sha1-NXEmxTZZSwZmjhh4c4Ey+sNciJY=",
"dev": true, "dev": true,
"requires": { "requires": {
"strophe.js": "1.2.16" "strophe.js": "github:strophe/strophejs#a2692dcfdaf7d591254ac73f3d8584992b6f8da7"
} }
}, },
"strophejs-plugin-register": { "strophejs-plugin-register": {
......
...@@ -97,32 +97,32 @@ ...@@ -97,32 +97,32 @@
return test_utils.waitUntil(() => sent_stanza); return test_utils.waitUntil(() => sent_stanza);
}).then(() => { }).then(() => {
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq from="dummy@localhost/resource" id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
"<publish node='storage:bookmarks'>"+ `<publish node="storage:bookmarks">`+
"<item id='current'>"+ `<item id="current">`+
"<storage xmlns='storage:bookmarks'>"+ `<storage xmlns="storage:bookmarks">`+
"<conference name='Play&amp;apos;s the Thing' autojoin='true' jid='theplay@conference.shakespeare.lit'>"+ `<conference autojoin="true" jid="theplay@conference.shakespeare.lit" name="Play&amp;apos;s the Thing">`+
"<nick>JC</nick>"+ `<nick>JC</nick>`+
"</conference>"+ `</conference>`+
"</storage>"+ `</storage>`+
"</item>"+ `</item>`+
"</publish>"+ `</publish>`+
"<publish-options>"+ `<publish-options>`+
"<x xmlns='jabber:x:data' type='submit'>"+ `<x type="submit" xmlns="jabber:x:data">`+
"<field var='FORM_TYPE' type='hidden'>"+ `<field type="hidden" var="FORM_TYPE">`+
"<value>http://jabber.org/protocol/pubsub#publish-options</value>"+ `<value>http://jabber.org/protocol/pubsub#publish-options</value>`+
"</field>"+ `</field>`+
"<field var='pubsub#persist_items'>"+ `<field var="pubsub#persist_items">`+
"<value>true</value>"+ `<value>true</value>`+
"</field>"+ `</field>`+
"<field var='pubsub#access_model'>"+ `<field var="pubsub#access_model">`+
"<value>whitelist</value>"+ `<value>whitelist</value>`+
"</field>"+ `</field>`+
"</x>"+ `</x>`+
"</publish-options>"+ `</publish-options>`+
"</pubsub>"+ `</pubsub>`+
"</iq>" `</iq>`
); );
/* Server acknowledges successful storage /* Server acknowledges successful storage
* *
...@@ -245,28 +245,28 @@ ...@@ -245,28 +245,28 @@
// conferences to bookmark (since we removed the one and // conferences to bookmark (since we removed the one and
// only bookmark). // only bookmark).
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq from="dummy@localhost/resource" id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
"<publish node='storage:bookmarks'>"+ `<publish node="storage:bookmarks">`+
"<item id='current'>"+ `<item id="current">`+
"<storage xmlns='storage:bookmarks'/>"+ `<storage xmlns="storage:bookmarks"/>`+
"</item>"+ `</item>`+
"</publish>"+ `</publish>`+
"<publish-options>"+ `<publish-options>`+
"<x xmlns='jabber:x:data' type='submit'>"+ `<x type="submit" xmlns="jabber:x:data">`+
"<field var='FORM_TYPE' type='hidden'>"+ `<field type="hidden" var="FORM_TYPE">`+
"<value>http://jabber.org/protocol/pubsub#publish-options</value>"+ `<value>http://jabber.org/protocol/pubsub#publish-options</value>`+
"</field>"+ `</field>`+
"<field var='pubsub#persist_items'>"+ `<field var="pubsub#persist_items">`+
"<value>true</value>"+ `<value>true</value>`+
"</field>"+ `</field>`+
"<field var='pubsub#access_model'>"+ `<field var="pubsub#access_model">`+
"<value>whitelist</value>"+ `<value>whitelist</value>`+
"</field>"+ `</field>`+
"</x>"+ `</x>`+
"</publish-options>"+ `</publish-options>`+
"</pubsub>"+ `</pubsub>`+
"</iq>" `</iq>`
); );
done(); done();
}); });
......
This diff is collapsed.
...@@ -223,9 +223,9 @@ ...@@ -223,9 +223,9 @@
input_name.value = 'Someone'; input_name.value = 'Someone';
modal.el.querySelector('button[type="submit"]').click(); modal.el.querySelector('button[type="submit"]').click();
expect(sent_stanza.toLocaleString()).toEqual( expect(sent_stanza.toLocaleString()).toEqual(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'><item jid='someone@localhost' name='Someone'/></query>"+ `<query xmlns="jabber:iq:roster"><item jid="someone@localhost" name="Someone"/></query>`+
"</iq>"); `</iq>`);
done(); done();
}); });
})); }));
...@@ -294,9 +294,9 @@ ...@@ -294,9 +294,9 @@
expect(modal.el.querySelector('input[name="jid"]').value).toBe('marty@mcfly.net'); expect(modal.el.querySelector('input[name="jid"]').value).toBe('marty@mcfly.net');
modal.el.querySelector('button[type="submit"]').click(); modal.el.querySelector('button[type="submit"]').click();
expect(sent_stanza.toLocaleString()).toEqual( expect(sent_stanza.toLocaleString()).toEqual(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'><item jid='marty@mcfly.net' name='Marty McFly'/></query>"+ `<query xmlns="jabber:iq:roster"><item jid="marty@mcfly.net" name="Marty McFly"/></query>`+
"</iq>"); `</iq>`);
window.XMLHttpRequest = XMLHttpRequestBackup; window.XMLHttpRequest = XMLHttpRequestBackup;
done(); done();
}); });
......
...@@ -74,14 +74,10 @@ ...@@ -74,14 +74,10 @@
i++; i++;
} }
expect(_converse.sendCSI).toHaveBeenCalledWith('inactive'); expect(_converse.sendCSI).toHaveBeenCalledWith('inactive');
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe('<inactive xmlns="urn:xmpp:csi:0"/>');
"<inactive xmlns='urn:xmpp:csi:0'/>"
);
_converse.onUserActivity(); _converse.onUserActivity();
expect(_converse.sendCSI).toHaveBeenCalledWith('active'); expect(_converse.sendCSI).toHaveBeenCalledWith('active');
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe('<active xmlns="urn:xmpp:csi:0"/>');
"<active xmlns='urn:xmpp:csi:0'/>"
);
// Reset values // Reset values
_converse.csi_waiting_time = 0; _converse.csi_waiting_time = 0;
_converse.disco_entities.get(_converse.domain).features['urn:xmpp:csi:0'] = false; _converse.disco_entities.get(_converse.domain).features['urn:xmpp:csi:0'] = false;
......
This diff is collapsed.
This diff is collapsed.
...@@ -69,12 +69,12 @@ ...@@ -69,12 +69,12 @@
const msg = _converse.connection.send.calls.all()[0].args[0]; const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString()) expect(msg.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${msg.nodeTree.getAttribute("id")}" `+
`to='max.frankfurter@localhost' type='chat' id='${msg.nodeTree.getAttribute('id')}' `+ `to="max.frankfurter@localhost" type="chat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>But soft, what light through yonder window breaks?</body>`+ `<body>But soft, what light through yonder window breaks?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<replace xmlns='urn:xmpp:message-correct:0' id='${first_msg.get('msgid')}'/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
const corrected_message = view.model.messages.at(0); const corrected_message = view.model.messages.at(0);
...@@ -172,12 +172,12 @@ ...@@ -172,12 +172,12 @@
const msg = _converse.connection.send.calls.all()[0].args[0]; const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString()) expect(msg.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${msg.nodeTree.getAttribute("id")}" `+
`to='max.frankfurter@localhost' type='chat' id='${msg.nodeTree.getAttribute('id')}' `+ `to="max.frankfurter@localhost" type="chat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>But soft, what light through yonder window breaks?</body>`+ `<body>But soft, what light through yonder window breaks?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<replace xmlns='urn:xmpp:message-correct:0' id='${first_msg.get('msgid')}'/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
const corrected_message = view.model.messages.at(0); const corrected_message = view.model.messages.at(0);
...@@ -2090,12 +2090,12 @@ ...@@ -2090,12 +2090,12 @@
const msg = _converse.connection.send.calls.all()[0].args[0]; const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString()) expect(msg.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${msg.nodeTree.getAttribute("id")}" `+
`to='lounge@localhost' type='groupchat' id='${msg.nodeTree.getAttribute('id')}' `+ `to="lounge@localhost" type="groupchat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>But soft, what light through yonder window breaks?</body>`+ `<body>But soft, what light through yonder window breaks?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<replace xmlns='urn:xmpp:message-correct:0' id='${first_msg.get('msgid')}'/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
...@@ -2291,14 +2291,14 @@ ...@@ -2291,14 +2291,14 @@
view.keyPressed(enter_event); view.keyPressed(enter_event);
const msg = _converse.connection.send.calls.all()[0].args[0]; const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString()) expect(msg.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${msg.nodeTree.getAttribute("id")}" `+
`to='lounge@localhost' type='groupchat' id='${msg.nodeTree.getAttribute('id')}' `+ `to="lounge@localhost" type="groupchat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`+ `<body>hello z3r0 gibson mr.robot, how are you?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='18' end='26' type='mention' uri='xmpp:mr.robot@localhost'/>`+ `<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='11' end='17' type='mention' uri='xmpp:gibson@localhost'/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='6' end='10' type='mention' uri='xmpp:z3r0@localhost'/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`</message>`); `</message>`);
const first_msg = view.model.messages.findWhere({'message': 'hello z3r0 gibson mr.robot, how are you?'}); const first_msg = view.model.messages.findWhere({'message': 'hello z3r0 gibson mr.robot, how are you?'});
...@@ -2316,15 +2316,15 @@ ...@@ -2316,15 +2316,15 @@
const correction = _converse.connection.send.calls.all()[1].args[0]; const correction = _converse.connection.send.calls.all()[1].args[0];
expect(correction.toLocaleString()) expect(correction.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${correction.nodeTree.getAttribute("id")}" `+
`to='lounge@localhost' type='groupchat' id='${correction.nodeTree.getAttribute('id')}' `+ `to="lounge@localhost" type="groupchat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>hello z3r0 gibson sw0rdf1sh, how are you?</body>`+ `<body>hello z3r0 gibson sw0rdf1sh, how are you?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='18' end='27' type='mention' uri='xmpp:sw0rdf1sh@localhost'/>`+ `<reference begin="18" end="27" type="mention" uri="xmpp:sw0rdf1sh@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='11' end='17' type='mention' uri='xmpp:gibson@localhost'/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='6' end='10' type='mention' uri='xmpp:z3r0@localhost'/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<replace xmlns='urn:xmpp:message-correct:0' id='${msg.nodeTree.getAttribute('id')}'/>`+ `<replace id="${msg.nodeTree.getAttribute("id")}" xmlns="urn:xmpp:message-correct:0"/>`+
`</message>`); `</message>`);
done(); done();
}).catch(_.partial(console.error, _)); }).catch(_.partial(console.error, _));
...@@ -2365,14 +2365,14 @@ ...@@ -2365,14 +2365,14 @@
const msg = _converse.connection.send.calls.all()[0].args[0]; const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString()) expect(msg.toLocaleString())
.toBe(`<message from='dummy@localhost/resource' `+ .toBe(`<message from="dummy@localhost/resource" id="${msg.nodeTree.getAttribute("id")}" `+
`to='lounge@localhost' type='groupchat' id='${msg.nodeTree.getAttribute('id')}' `+ `to="lounge@localhost" type="groupchat" `+
`xmlns='jabber:client'>`+ `xmlns="jabber:client">`+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`+ `<body>hello z3r0 gibson mr.robot, how are you?</body>`+
`<active xmlns='http://jabber.org/protocol/chatstates'/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='18' end='26' type='mention' uri='xmpp:mr.robot@localhost'/>`+ `<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='11' end='17' type='mention' uri='xmpp:gibson@localhost'/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference xmlns='urn:xmpp:reference:0' begin='6' end='10' type='mention' uri='xmpp:z3r0@localhost'/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`</message>`); `</message>`);
done(); done();
}).catch(_.partial(console.error, _)); }).catch(_.partial(console.error, _));
......
This diff is collapsed.
...@@ -44,9 +44,9 @@ ...@@ -44,9 +44,9 @@
}); });
_converse.ping(); _converse.ping();
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<iq type='get' to='localhost' id='"+IQ_id+"' xmlns='jabber:client'>"+ `<iq id="${IQ_id}" to="localhost" type="get" xmlns="jabber:client">`+
"<ping xmlns='urn:xmpp:ping'/>"+ `<ping xmlns="urn:xmpp:ping"/>`+
"</iq>"); `</iq>`);
})); }));
}); });
}); });
......
...@@ -34,42 +34,42 @@ ...@@ -34,42 +34,42 @@
const presence = _converse.xmppstatus.constructPresence(); const presence = _converse.xmppstatus.constructPresence();
expect(presence.toLocaleString()).toBe( expect(presence.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+ `<presence xmlns="jabber:client">`+
"<priority>0</priority>"+ `<priority>0</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='QgayPKawpkPSDYmwT/WM94uAlu0='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="QgayPKawpkPSDYmwT/WM94uAlu0=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>") `</presence>`)
done(); done();
})); }));
it("has a given priority", mock.initConverse(function (_converse) { it("has a given priority", mock.initConverse(function (_converse) {
var pres = _converse.xmppstatus.constructPresence('online', 'Hello world'); var pres = _converse.xmppstatus.constructPresence('online', 'Hello world');
expect(pres.toLocaleString()).toBe( expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+ `<presence xmlns="jabber:client">`+
"<status>Hello world</status>"+ `<status>Hello world</status>`+
"<priority>0</priority>"+ `<priority>0</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='K7kn/M6VtmdMyo61pgn/jkZlax8='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="K7kn/M6VtmdMyo61pgn/jkZlax8=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>" `</presence>`
); );
_converse.priority = 2; _converse.priority = 2;
pres = _converse.xmppstatus.constructPresence('away', 'Going jogging'); pres = _converse.xmppstatus.constructPresence('away', 'Going jogging');
expect(pres.toLocaleString()).toBe( expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+ `<presence xmlns="jabber:client">`+
"<show>away</show>"+ `<show>away</show>`+
"<status>Going jogging</status>"+ `<status>Going jogging</status>`+
"<priority>2</priority>"+ `<priority>2</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='K7kn/M6VtmdMyo61pgn/jkZlax8='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="K7kn/M6VtmdMyo61pgn/jkZlax8=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>" `</presence>`
); );
delete _converse.priority; delete _converse.priority;
pres = _converse.xmppstatus.constructPresence('dnd', 'Doing taxes'); pres = _converse.xmppstatus.constructPresence('dnd', 'Doing taxes');
expect(pres.toLocaleString()).toBe( expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+ `<presence xmlns="jabber:client">`+
"<show>dnd</show>"+ `<show>dnd</show>`+
"<status>Doing taxes</status>"+ `<status>Doing taxes</status>`+
"<priority>0</priority>"+ `<priority>0</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='K7kn/M6VtmdMyo61pgn/jkZlax8='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="K7kn/M6VtmdMyo61pgn/jkZlax8=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>" `</presence>`
); );
})); }));
...@@ -94,27 +94,23 @@ ...@@ -94,27 +94,23 @@
modal.el.querySelector('[type="submit"]').click(); modal.el.querySelector('[type="submit"]').click();
expect(view.model.sendPresence).toHaveBeenCalled(); expect(view.model.sendPresence).toHaveBeenCalled();
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString()) expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
.toBe("<presence xmlns='jabber:client'>"+ .toBe(`<presence xmlns="jabber:client">`+
"<status>My custom status</status>"+ `<status>My custom status</status>`+
"<priority>0</priority>"+ `<priority>0</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='K7kn/M6VtmdMyo61pgn/jkZlax8='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="K7kn/M6VtmdMyo61pgn/jkZlax8=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>") `</presence>`)
return test_utils.waitUntil(function () { return test_utils.waitUntil(() => modal.el.getAttribute('aria-hidden') === "true");
return modal.el.getAttribute('aria-hidden') === "true";
});
}).then(function () { }).then(function () {
cbview.el.querySelector('.change-status').click() cbview.el.querySelector('.change-status').click()
return test_utils.waitUntil(function () { return test_utils.waitUntil(() => modal.el.getAttribute('aria-hidden') === "false", 1000);
return modal.el.getAttribute('aria-hidden') === "false";
}, 1000);
}).then(function () { }).then(function () {
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.connection.send.calls.mostRecent().args[0].toLocaleString()) expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
.toBe("<presence xmlns='jabber:client'><show>dnd</show><status>My custom status</status><priority>0</priority>"+ .toBe(`<presence xmlns="jabber:client"><show>dnd</show><status>My custom status</status><priority>0</priority>`+
"<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://conversejs.org' ver='K7kn/M6VtmdMyo61pgn/jkZlax8='/>"+ `<c hash="sha-1" node="https://conversejs.org" ver="K7kn/M6VtmdMyo61pgn/jkZlax8=" xmlns="http://jabber.org/protocol/caps"/>`+
"</presence>") `</presence>`)
done(); done();
}); });
})); }));
......
...@@ -121,11 +121,11 @@ ...@@ -121,11 +121,11 @@
*/ */
expect(_converse.roster.sendContactAddIQ).toHaveBeenCalled(); expect(_converse.roster.sendContactAddIQ).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'>"+ `<query xmlns="jabber:iq:roster">`+
"<item jid='contact@example.org' name='contact@example.org'/>"+ `<item jid="contact@example.org" name="contact@example.org"/>`+
"</query>"+ `</query>`+
"</iq>" `</iq>`
); );
/* As a result, the user's server (1) MUST initiate a roster push /* As a result, the user's server (1) MUST initiate a roster push
* for the new roster item to all available resources associated * for the new roster item to all available resources associated
...@@ -185,9 +185,9 @@ ...@@ -185,9 +185,9 @@
}).then(function () { }).then(function () {
expect(contact.subscribe).toHaveBeenCalled(); expect(contact.subscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec) expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
"<presence to='contact@example.org' type='subscribe' xmlns='jabber:client'>"+ `<presence to="contact@example.org" type="subscribe" xmlns="jabber:client">`+
"<nick xmlns='http://jabber.org/protocol/nick'>Max Mustermann</nick>"+ `<nick xmlns="http://jabber.org/protocol/nick">Max Mustermann</nick>`+
"</presence>" `</presence>`
); );
/* As a result, the user's server MUST initiate a second roster /* As a result, the user's server MUST initiate a second roster
* push to all of the user's available resources that have * push to all of the user's available resources that have
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
*/ */
expect(contact.ackSubscribe).toHaveBeenCalled(); expect(contact.ackSubscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec) expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
"<presence type='subscribe' to='contact@example.org' xmlns='jabber:client'/>" `<presence to="contact@example.org" type="subscribe" xmlns="jabber:client"/>`
); );
/* The user's server MUST initiate a roster push to all of the user's /* The user's server MUST initiate a roster push to all of the user's
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
// Check that the IQ set was acknowledged. // Check that the IQ set was acknowledged.
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec) expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
"<iq type='result' id='"+IQ_id+"' from='dummy@localhost/resource' xmlns='jabber:client'/>" `<iq from="dummy@localhost/resource" id="${IQ_id}" type="result" xmlns="jabber:client"/>`
); );
expect(_converse.roster.updateContact).toHaveBeenCalled(); expect(_converse.roster.updateContact).toHaveBeenCalled();
...@@ -341,7 +341,7 @@ ...@@ -341,7 +341,7 @@
*/ */
expect(contact.authorize).toHaveBeenCalled(); expect(contact.authorize).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<presence to='contact@example.org' type='subscribed' xmlns='jabber:client'/>" `<presence to="contact@example.org" type="subscribed" xmlns="jabber:client"/>`
); );
/* As a result, the user's server MUST initiate a /* As a result, the user's server MUST initiate a
...@@ -446,18 +446,18 @@ ...@@ -446,18 +446,18 @@
*/ */
expect(contact.ackUnsubscribe).toHaveBeenCalled(); expect(contact.ackUnsubscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( expect(sent_stanza.toLocaleString()).toBe(
"<presence type='unsubscribe' to='contact@example.org' xmlns='jabber:client'/>" `<presence to="contact@example.org" type="unsubscribe" xmlns="jabber:client"/>`
); );
/* _converse.js will then also automatically remove the /* _converse.js will then also automatically remove the
* contact from the user's roster. * contact from the user's roster.
*/ */
expect(sent_IQ.toLocaleString()).toBe( expect(sent_IQ.toLocaleString()).toBe(
"<iq type='set' xmlns='jabber:client'>"+ `<iq type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'>"+ `<query xmlns="jabber:iq:roster">`+
"<item jid='contact@example.org' subscription='remove'/>"+ `<item jid="contact@example.org" subscription="remove"/>`+
"</query>"+ `</query>`+
"</iq>" `</iq>`
); );
done(); done();
})); }));
...@@ -511,11 +511,11 @@ ...@@ -511,11 +511,11 @@
* </iq> * </iq>
*/ */
expect(sent_IQ.toLocaleString()).toBe( expect(sent_IQ.toLocaleString()).toBe(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ `<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'>"+ `<query xmlns="jabber:iq:roster">`+
"<item jid='annegreet.gomez@localhost' subscription='remove'/>"+ `<item jid="annegreet.gomez@localhost" subscription="remove"/>`+
"</query>"+ `</query>`+
"</iq>"); `</iq>`);
// Receive confirmation from the contact's server // Receive confirmation from the contact's server
// <iq type='result' id='remove1'/> // <iq type='result' id='remove1'/>
......
...@@ -33,19 +33,14 @@ ...@@ -33,19 +33,14 @@
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info')) ['urn:xmpp:push:0'], [], 'info'))
.then(() => { .then(() => {
return test_utils.waitUntil(() => { return test_utils.waitUntil(() =>
const node = _.filter(IQ_stanzas, function (iq) { _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()
return iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]'); )
}).pop(); }).then(node => {
if (node) { const stanza = node.nodeTree;
stanza = node.nodeTree; expect(node.toLocaleString()).toEqual(
return true; `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
} '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
})
}).then(() => {
expect(stanza.outerHTML).toEqual(
`<iq type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
'<enable xmlns="urn:xmpp:push:0" jid="push-5@client.example" node="yxs32uqsflafdk3iuqo"/>'+
'</iq>' '</iq>'
) )
_converse.connection._dataRecv(test_utils.createRequest($iq({ _converse.connection._dataRecv(test_utils.createRequest($iq({
...@@ -85,9 +80,9 @@ ...@@ -85,9 +80,9 @@
return test_utils.waitUntil( return test_utils.waitUntil(
() => _.filter(IQ_stanzas, (iq) => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()) () => _.filter(IQ_stanzas, (iq) => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop())
}).then(stanza => { }).then(stanza => {
expect(stanza.nodeTree.outerHTML).toEqual( expect(stanza.toLocaleString()).toEqual(
`<iq type="set" xmlns="jabber:client" to="chat.shakespeare.lit" id="${stanza.nodeTree.getAttribute('id')}">`+ `<iq id="${stanza.nodeTree.getAttribute('id')}" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
'<enable xmlns="urn:xmpp:push:0" jid="push-5@client.example" node="yxs32uqsflafdk3iuqo"/>'+ '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
'</iq>' '</iq>'
) )
_converse.connection._dataRecv(test_utils.createRequest($iq({ _converse.connection._dataRecv(test_utils.createRequest($iq({
...@@ -111,7 +106,6 @@ ...@@ -111,7 +106,6 @@
const IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
let stanza; let stanza;
expect(_converse.session.get('push_enabled')).toBeFalsy(); expect(_converse.session.get('push_enabled')).toBeFalsy();
test_utils.waitUntilDiscoConfirmed( test_utils.waitUntilDiscoConfirmed(
...@@ -119,20 +113,13 @@ ...@@ -119,20 +113,13 @@
_converse.bare_jid, _converse.bare_jid,
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info') ['urn:xmpp:push:0'], [], 'info')
.then(() => { .then(() => test_utils.waitUntil(
return test_utils.waitUntil(() => { () => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] disable[xmlns="urn:xmpp:push:0"]')).pop()
const node = _.filter(IQ_stanzas, function (iq) { )).then(node => {
return iq.nodeTree.querySelector('iq[type="set"] disable[xmlns="urn:xmpp:push:0"]'); const stanza = node.nodeTree;
}).pop(); expect(node.toLocaleString()).toEqual(
if (node) { `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
stanza = node.nodeTree; '<disable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
return true;
}
})
}).then(() => {
expect(stanza.outerHTML).toEqual(
`<iq type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
'<disable xmlns="urn:xmpp:push:0" jid="push-5@client.example" node="yxs32uqsflafdk3iuqo"/>'+
'</iq>' '</iq>'
) )
_converse.connection._dataRecv(test_utils.createRequest($iq({ _converse.connection._dataRecv(test_utils.createRequest($iq({
...@@ -168,21 +155,14 @@ ...@@ -168,21 +155,14 @@
_converse.bare_jid, _converse.bare_jid,
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info')) ['urn:xmpp:push:0'], [], 'info'))
.then(() => { .then(() => test_utils.waitUntil(
return test_utils.waitUntil(() => { () => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()
const node = _.filter(IQ_stanzas, function (iq) { )).then(node => {
return iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]'); const stanza = node.nodeTree;
}).pop(); expect(node.toLocaleString()).toEqual(
if (node) { `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
stanza = node.nodeTree; '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0">'+
return true; '<x type="submit" xmlns="jabber:x:data">'+
}
})
}).then(() => {
expect(stanza.outerHTML).toEqual(
`<iq type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
'<enable xmlns="urn:xmpp:push:0" jid="push-5@client.example" node="yxs32uqsflafdk3iuqo">'+
'<x xmlns="jabber:x:data" type="submit">'+
'<field var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#publish-options</value></field>'+ '<field var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#publish-options</value></field>'+
'<field var="secret"><value>eruio234vzxc2kla-91</value></field>'+ '<field var="secret"><value>eruio234vzxc2kla-91</value></field>'+
'</x>'+ '</x>'+
......
...@@ -265,17 +265,17 @@ ...@@ -265,17 +265,17 @@
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
stanza = _converse.connection.send.calls.argsFor(0)[0].tree(); stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
expect(stanza.outerHTML.trim().replace(/(\n|\s{2,})/g, '')).toEqual( expect(Strophe.serialize(stanza).toLocaleString().trim().replace(/(\n|\s{2,})/g, '')).toEqual(
'<iq type="set" id="'+stanza.getAttribute('id')+'" xmlns="jabber:client">'+ '<iq id="'+stanza.getAttribute('id')+'" type="set" xmlns="jabber:client">'+
'<query xmlns="jabber:iq:register">'+ '<query xmlns="jabber:iq:register">'+
'<x xmlns="jabber:x:data" type="submit">'+ '<x type="submit" xmlns="jabber:x:data">'+
'<field xmlns="http://www.w3.org/1999/xhtml" var="username">'+ '<field var="username">'+
'<value>testusername</value>'+ '<value>testusername</value>'+
'</field>'+ '</field>'+
'<field xmlns="http://www.w3.org/1999/xhtml" var="password">'+ '<field var="password">'+
'<value>testpassword</value>'+ '<value>testpassword</value>'+
'</field>'+ '</field>'+
'<field xmlns="http://www.w3.org/1999/xhtml" var="email">'+ '<field var="email">'+
'<value>test@email.local</value>'+ '<value>test@email.local</value>'+
'</field>'+ '</field>'+
'</x>'+ '</x>'+
......
...@@ -30,14 +30,15 @@ ...@@ -30,14 +30,15 @@
preventDefault: _.noop, preventDefault: _.noop,
keyCode: 13 keyCode: 13
}); });
return test_utils.waitUntil(() => _.get(_.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
).pop(), 'nodeTree')); ).pop());
}).then(stanza => { }).then(node => {
expect(stanza.outerHTML) const stanza = node.nodeTree;
.toBe(`<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" `+ expect(node.toLocaleString())
`type="get" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+ .toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+
`type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register"/></iq>`); `<query xmlns="jabber:iq:register"/></iq>`);
view = _converse.chatboxviews.get(room_jid); view = _converse.chatboxviews.get(room_jid);
const result = $iq({ const result = $iq({
...@@ -53,15 +54,16 @@ ...@@ -53,15 +54,16 @@
'var': 'muc#register_roomnick' 'var': 'muc#register_roomnick'
}).c('required'); }).c('required');
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
return test_utils.waitUntil(() => _.get(_.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
).pop(), 'nodeTree')); ).pop());
}).then(stanza => { }).then(node => {
expect(stanza.outerHTML).toBe( const stanza = node.nodeTree;
`<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+ expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register">`+ `<query xmlns="jabber:iq:register">`+
`<x xmlns="jabber:x:data" type="submit">`+ `<x type="submit" xmlns="jabber:x:data">`+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+ `<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+
`<field var="muc#register_roomnick"><value>romeo</value></field>`+ `<field var="muc#register_roomnick"><value>romeo</value></field>`+
`</x>`+ `</x>`+
...@@ -123,14 +125,15 @@ ...@@ -123,14 +125,15 @@
}).up() }).up()
.c('status').attrs({code:'110'}); .c('status').attrs({code:'110'});
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
return test_utils.waitUntil(() => _.get(_.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
).pop(), 'nodeTree')); ).pop());
}).then(stanza => { }).then(node => {
expect(stanza.outerHTML) const stanza = node.nodeTree;
.toBe(`<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" `+ expect(node.toLocaleString())
`type="get" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+ .toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+
`type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register"/></iq>`); `<query xmlns="jabber:iq:register"/></iq>`);
view = _converse.chatboxviews.get(room_jid); view = _converse.chatboxviews.get(room_jid);
const result = $iq({ const result = $iq({
...@@ -146,15 +149,16 @@ ...@@ -146,15 +149,16 @@
'var': 'muc#register_roomnick' 'var': 'muc#register_roomnick'
}).c('required'); }).c('required');
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
return test_utils.waitUntil(() => _.get(_.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
).pop(), 'nodeTree')); ).pop());
}).then(stanza => { }).then(node => {
expect(stanza.outerHTML).toBe( const stanza = node.nodeTree;
`<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+ expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register">`+ `<query xmlns="jabber:iq:register">`+
`<x xmlns="jabber:x:data" type="submit">`+ `<x type="submit" xmlns="jabber:x:data">`+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+ `<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+
`<field var="muc#register_roomnick"><value>romeo</value></field>`+ `<field var="muc#register_roomnick"><value>romeo</value></field>`+
`</x>`+ `</x>`+
......
...@@ -40,21 +40,14 @@ ...@@ -40,21 +40,14 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
var IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
var stanza; test_utils.waitUntil(
() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq query[xmlns="jabber:iq:roster"]')).pop()
test_utils.waitUntil(() => { ).then(node => {
const node = _.filter(IQ_stanzas, function (iq) { let stanza = node.nodeTree;
return iq.nodeTree.querySelector('iq query[xmlns="jabber:iq:roster"]');
}).pop();
if (node) {
stanza = node.nodeTree;
return true;
}
}).then(() => {
expect(_converse.roster.data.get('version')).toBeUndefined(); expect(_converse.roster.data.get('version')).toBeUndefined();
expect(stanza.outerHTML).toBe( expect(node.toLocaleString()).toBe(
`<iq type="get" id="${stanza.getAttribute('id')}" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:roster"/>`+ `<query xmlns="jabber:iq:roster"/>`+
`</iq>`); `</iq>`);
let result = $iq({ let result = $iq({
...@@ -71,10 +64,11 @@ ...@@ -71,10 +64,11 @@
expect(_converse.roster.models.length).toBe(2); expect(_converse.roster.models.length).toBe(2);
_converse.roster.fetchFromServer(); _converse.roster.fetchFromServer();
stanza = _converse.connection.IQ_stanzas.pop().nodeTree; node = _converse.connection.IQ_stanzas.pop();
expect(stanza.outerHTML).toBe( stanza = node.nodeTree;
`<iq type="get" id="${stanza.getAttribute('id')}" xmlns="jabber:client">`+ expect(node.toLocaleString()).toBe(
`<query xmlns="jabber:iq:roster" ver="ver7"/>`+ `<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
`<query ver="ver7" xmlns="jabber:iq:roster"/>`+
`</iq>`); `</iq>`);
result = $iq({ result = $iq({
...@@ -656,11 +650,11 @@ ...@@ -656,11 +650,11 @@
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
expect(contact.removeFromRoster).toHaveBeenCalled(); expect(contact.removeFromRoster).toHaveBeenCalled();
expect(sent_IQ.toLocaleString()).toBe( expect(sent_IQ.toLocaleString()).toBe(
"<iq type='set' xmlns='jabber:client'>"+ `<iq type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'>"+ `<query xmlns="jabber:iq:roster">`+
"<item jid='suleyman.van.beusichem@localhost' subscription='remove'/>"+ `<item jid="suleyman.van.beusichem@localhost" subscription="remove"/>`+
"</query>"+ `</query>`+
"</iq>"); `</iq>`);
done(); done();
}); });
})); }));
...@@ -851,9 +845,9 @@ ...@@ -851,9 +845,9 @@
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
expect(sent_IQ.toLocaleString()).toBe( expect(sent_IQ.toLocaleString()).toBe(
"<iq type='set' xmlns='jabber:client'>"+ `<iq type="set" xmlns="jabber:client">`+
"<query xmlns='jabber:iq:roster'><item jid='max.frankfurter@localhost' subscription='remove'/></query>"+ `<query xmlns="jabber:iq:roster"><item jid="max.frankfurter@localhost" subscription="remove"/></query>`+
"</iq>"); `</iq>`);
expect(contact.removeFromRoster).toHaveBeenCalled(); expect(contact.removeFromRoster).toHaveBeenCalled();
expect($(_converse.rosterview.el).find(".open-chat:contains('"+name+"')").length).toEqual(0); expect($(_converse.rosterview.el).find(".open-chat:contains('"+name+"')").length).toEqual(0);
done(); done();
......
...@@ -69,19 +69,9 @@ ...@@ -69,19 +69,9 @@
dependencies: ["converse-chatboxes", "converse-disco", "converse-controlbox"], dependencies: ["converse-chatboxes", "converse-disco", "converse-controlbox"],
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the
// relevant objects or classes.
//
// New functions which don't exist yet can also be added.
tearDown () { tearDown () {
const { _converse } = this.__super__, const groupchats = this.chatboxes.where({'type': this.CHATROOMS_TYPE});
groupchats = this.chatboxes.where({'type': _converse.CHATROOMS_TYPE}); _.each(groupchats, gc => u.safeSave(gc, {'connection_status': this.ROOMSTATUS.DISCONNECTED}));
_.each(groupchats, function (groupchat) {
u.safeSave(groupchat, {'connection_status': converse.ROOMSTATUS.DISCONNECTED});
});
this.__super__.tearDown.call(this, arguments); this.__super__.tearDown.call(this, arguments);
}, },
......
...@@ -106,7 +106,7 @@ const config = { ...@@ -106,7 +106,7 @@ const config = {
"snabbdom-eventlisteners": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-eventlisteners"), "snabbdom-eventlisteners": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-eventlisteners"),
"snabbdom-props": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-props"), "snabbdom-props": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-props"),
"snabbdom-style": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-style"), "snabbdom-style": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-style"),
"strophe": path.resolve(__dirname, "node_modules/strophe.js/strophe"), "strophe": path.resolve(__dirname, "node_modules/strophe.js/dist/strophe"),
"strophe.ping": path.resolve(__dirname, "node_modules/strophejs-plugin-ping/strophe.ping"), "strophe.ping": path.resolve(__dirname, "node_modules/strophejs-plugin-ping/strophe.ping"),
"strophe.rsm": path.resolve(__dirname, "node_modules/strophejs-plugin-rsm/strophe.rsm"), "strophe.rsm": path.resolve(__dirname, "node_modules/strophejs-plugin-rsm/strophe.rsm"),
"tovnode": path.resolve(__dirname, "node_modules/snabbdom/dist/tovnode"), "tovnode": path.resolve(__dirname, "node_modules/snabbdom/dist/tovnode"),
......
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