Skip to content

Commit 445ff4f

Browse files
committed
Rewrite test to avoid connection spy
1 parent 6253dd5 commit 445ff4f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

spec/roomslist.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,16 @@
7979
[`${Strophe.NS.PUBSUB}#publish-options`]
8080
);
8181

82-
const call = await u.waitUntil(() =>
83-
_.filter(
84-
_converse.connection.send.calls.all(),
85-
c => sizzle('items[node="storage:bookmarks"]', c.args[0]).length
86-
).pop()
87-
);
88-
expect(Strophe.serialize(call.args[0])).toBe(
89-
`<iq from="[email protected]/orchard" id="${call.args[0].getAttribute('id')}" type="get" xmlns="jabber:client">`+
82+
const IQ_stanzas = _converse.connection.IQ_stanzas;
83+
const sent_stanza = await u.waitUntil(() => IQ_stanzas.filter(s => sizzle('items[node="storage:bookmarks"]', s).length).pop());
84+
expect(Strophe.serialize(sent_stanza)).toBe(
85+
`<iq from="[email protected]/orchard" id="${sent_stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
9086
'<pubsub xmlns="http://jabber.org/protocol/pubsub">'+
9187
'<items node="storage:bookmarks"/>'+
9288
'</pubsub>'+
9389
'</iq>');
9490

95-
stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id':call.args[0].getAttribute('id')})
91+
stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id':sent_stanza.getAttribute('id')})
9692
.c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
9793
.c('items', {'node': 'storage:bookmarks'})
9894
.c('item', {'id': 'current'})

0 commit comments

Comments
 (0)