2016-02-19 14:02:42 +01:00
|
|
|
(function (root, factory) {
|
2018-06-03 16:40:20 +02:00
|
|
|
define(["jasmine", "mock", "test-utils"], factory);
|
2017-06-19 11:08:57 +02:00
|
|
|
} (this, function (jasmine, mock, test_utils) {
|
2016-02-19 14:02:42 +01:00
|
|
|
"use strict";
|
2019-08-10 12:26:07 +02:00
|
|
|
const Strophe = converse.env.Strophe;
|
|
|
|
const u = converse.env.utils;
|
2016-02-19 14:02:42 +01:00
|
|
|
|
2017-07-11 10:41:11 +02:00
|
|
|
|
2019-08-10 12:26:07 +02:00
|
|
|
describe("XMPP Ping", function () {
|
2016-03-21 10:53:09 +01:00
|
|
|
|
2019-08-10 12:26:07 +02:00
|
|
|
describe("An IQ stanza", function () {
|
2017-07-11 10:41:11 +02:00
|
|
|
|
2019-08-10 12:26:07 +02:00
|
|
|
it("is returned when converse.js gets pinged", mock.initConverse((done, _converse) => {
|
|
|
|
const ping = u.toStanza(`
|
|
|
|
<iq from="${_converse.domain}"
|
|
|
|
to="${_converse.jid}" id="s2c1" type="get">
|
|
|
|
<ping xmlns="urn:xmpp:ping"/>
|
|
|
|
</iq>`);
|
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(ping));
|
|
|
|
const sent_stanza = _converse.connection.IQ_stanzas.pop();
|
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq id="s2c1" to="${_converse.domain}" type="result" xmlns="jabber:client"/>`);
|
2017-07-11 10:41:11 +02:00
|
|
|
done();
|
2016-11-03 11:01:09 +01:00
|
|
|
}));
|
|
|
|
|
2019-08-10 12:26:07 +02:00
|
|
|
it("is sent out when converse.js pings a server", mock.initConverse((done, _converse) => {
|
|
|
|
_converse.api.ping();
|
|
|
|
const sent_stanza = _converse.connection.IQ_stanzas.pop();
|
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq id="${sent_stanza.getAttribute('id')}" to="montague.lit" type="get" xmlns="jabber:client">`+
|
2018-10-02 17:01:39 +02:00
|
|
|
`<ping xmlns="urn:xmpp:ping"/>`+
|
|
|
|
`</iq>`);
|
2019-02-12 14:21:45 +01:00
|
|
|
done();
|
2016-11-03 11:01:09 +01:00
|
|
|
}));
|
2016-03-21 10:53:09 +01:00
|
|
|
});
|
|
|
|
});
|
2016-02-19 14:02:42 +01:00
|
|
|
}));
|