2017-02-20 22:27:34 +01:00
|
|
|
/*jshint sub:true*/
|
2017-02-21 10:00:56 +01:00
|
|
|
/*eslint dot-notation: "off"*/
|
2017-02-20 20:47:08 +01:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
2017-06-19 11:08:57 +02:00
|
|
|
"jasmine",
|
2017-02-20 20:47:08 +01:00
|
|
|
"mock",
|
2017-04-05 11:01:31 +02:00
|
|
|
"test-utils",
|
2018-06-03 16:40:20 +02:00
|
|
|
], factory);
|
2019-02-12 14:21:45 +01:00
|
|
|
} (this, function (jasmine, mock, test_utils) {
|
2017-02-20 20:47:08 +01:00
|
|
|
"use strict";
|
2019-02-12 14:21:45 +01:00
|
|
|
const u = converse.env.utils;
|
2017-02-20 20:47:08 +01:00
|
|
|
// See: https://xmpp.org/rfcs/rfc3921.html
|
|
|
|
|
2017-02-22 22:13:23 +01:00
|
|
|
describe("A sent presence stanza", function () {
|
|
|
|
|
2018-05-11 13:31:48 +02:00
|
|
|
it("includes a entity capabilities node",
|
2019-02-12 14:21:45 +01:00
|
|
|
mock.initConverse(
|
2019-10-11 16:38:01 +02:00
|
|
|
['rosterGroupsFetched'], {},
|
2019-02-12 14:21:45 +01:00
|
|
|
(done, _converse) => {
|
2018-05-11 13:31:48 +02:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.api.disco.own.identities.clear();
|
|
|
|
_converse.api.disco.own.features.clear();
|
2018-05-11 13:31:48 +02:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.api.disco.own.identities.add("client", "pc", "Exodus 0.9.1");
|
|
|
|
_converse.api.disco.own.features.add("http://jabber.org/protocol/caps");
|
|
|
|
_converse.api.disco.own.features.add("http://jabber.org/protocol/disco#info");
|
|
|
|
_converse.api.disco.own.features.add("http://jabber.org/protocol/disco#items");
|
|
|
|
_converse.api.disco.own.features.add("http://jabber.org/protocol/muc");
|
2018-05-11 13:31:48 +02:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
const presence = _converse.xmppstatus.constructPresence();
|
|
|
|
expect(presence.toLocaleString()).toBe(
|
|
|
|
`<presence xmlns="jabber:client">`+
|
|
|
|
`<priority>0</priority>`+
|
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="QgayPKawpkPSDYmwT/WM94uAlu0=" xmlns="http://jabber.org/protocol/caps"/>`+
|
|
|
|
`</presence>`)
|
|
|
|
done();
|
2018-05-11 13:31:48 +02:00
|
|
|
}));
|
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
it("has a given priority", mock.initConverse((done, _converse) => {
|
|
|
|
let pres = _converse.xmppstatus.constructPresence('online', 'Hello world');
|
2017-02-22 22:13:23 +01:00
|
|
|
expect(pres.toLocaleString()).toBe(
|
2018-10-02 17:01:39 +02:00
|
|
|
`<presence xmlns="jabber:client">`+
|
|
|
|
`<status>Hello world</status>`+
|
|
|
|
`<priority>0</priority>`+
|
2018-11-12 18:46:03 +01:00
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
|
2018-10-02 17:01:39 +02:00
|
|
|
`</presence>`
|
2017-02-22 22:13:23 +01:00
|
|
|
);
|
|
|
|
_converse.priority = 2;
|
|
|
|
pres = _converse.xmppstatus.constructPresence('away', 'Going jogging');
|
|
|
|
expect(pres.toLocaleString()).toBe(
|
2018-10-02 17:01:39 +02:00
|
|
|
`<presence xmlns="jabber:client">`+
|
|
|
|
`<show>away</show>`+
|
|
|
|
`<status>Going jogging</status>`+
|
|
|
|
`<priority>2</priority>`+
|
2018-11-12 18:46:03 +01:00
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
|
2018-10-02 17:01:39 +02:00
|
|
|
`</presence>`
|
2017-02-22 22:13:23 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
delete _converse.priority;
|
|
|
|
pres = _converse.xmppstatus.constructPresence('dnd', 'Doing taxes');
|
|
|
|
expect(pres.toLocaleString()).toBe(
|
2018-10-02 17:01:39 +02:00
|
|
|
`<presence xmlns="jabber:client">`+
|
|
|
|
`<show>dnd</show>`+
|
|
|
|
`<status>Doing taxes</status>`+
|
|
|
|
`<priority>0</priority>`+
|
2018-11-12 18:46:03 +01:00
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
|
2018-10-02 17:01:39 +02:00
|
|
|
`</presence>`
|
2017-02-22 22:13:23 +01:00
|
|
|
);
|
2019-02-12 14:21:45 +01:00
|
|
|
done();
|
2017-02-22 22:13:23 +01:00
|
|
|
}));
|
2018-03-02 19:35:06 +01:00
|
|
|
|
|
|
|
it("includes the saved status message",
|
2019-02-12 14:21:45 +01:00
|
|
|
mock.initConverse(
|
2019-10-11 16:38:01 +02:00
|
|
|
['rosterGroupsFetched'], {},
|
2019-02-12 14:21:45 +01:00
|
|
|
async (done, _converse) => {
|
2018-03-02 19:35:06 +01:00
|
|
|
|
2019-10-24 14:29:15 +02:00
|
|
|
test_utils.openControlBox(_converse);
|
2019-02-12 14:21:45 +01:00
|
|
|
const view = _converse.xmppstatusview;
|
2018-03-02 19:35:06 +01:00
|
|
|
spyOn(view.model, 'sendPresence').and.callThrough();
|
|
|
|
spyOn(_converse.connection, 'send').and.callThrough();
|
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
const cbview = _converse.chatboxviews.get('controlbox');
|
2018-03-17 00:37:52 +01:00
|
|
|
cbview.el.querySelector('.change-status').click()
|
2019-02-12 14:21:45 +01:00
|
|
|
const modal = _converse.xmppstatusview.status_modal;
|
2019-07-11 22:50:30 +02:00
|
|
|
await u.waitUntil(() => u.isVisible(modal.el), 1000);
|
2019-02-12 14:21:45 +01:00
|
|
|
const msg = 'My custom status';
|
|
|
|
modal.el.querySelector('input[name="status_message"]').value = msg;
|
|
|
|
modal.el.querySelector('[type="submit"]').click();
|
|
|
|
expect(view.model.sendPresence).toHaveBeenCalled();
|
|
|
|
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
|
|
|
|
.toBe(`<presence xmlns="jabber:client">`+
|
|
|
|
`<status>My custom status</status>`+
|
|
|
|
`<priority>0</priority>`+
|
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
|
|
|
|
`</presence>`)
|
2018-03-02 19:35:06 +01:00
|
|
|
|
2019-07-11 22:50:30 +02:00
|
|
|
await u.waitUntil(() => modal.el.getAttribute('aria-hidden') === "true");
|
2020-02-10 11:23:55 +01:00
|
|
|
await u.waitUntil(() => !u.isVisible(modal.el));
|
2019-02-12 14:21:45 +01:00
|
|
|
cbview.el.querySelector('.change-status').click()
|
2019-07-11 22:50:30 +02:00
|
|
|
await u.waitUntil(() => modal.el.getAttribute('aria-hidden') === "false", 1000);
|
2019-02-12 14:21:45 +01:00
|
|
|
modal.el.querySelector('label[for="radio-busy"]').click(); // Change status to "dnd"
|
|
|
|
modal.el.querySelector('[type="submit"]').click();
|
|
|
|
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>`+
|
|
|
|
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
|
|
|
|
`</presence>`)
|
|
|
|
done();
|
2018-03-02 19:35:06 +01:00
|
|
|
}));
|
2017-02-22 22:13:23 +01:00
|
|
|
});
|
|
|
|
|
2017-02-20 20:47:08 +01:00
|
|
|
describe("A received presence stanza", function () {
|
|
|
|
|
2017-07-11 10:41:11 +02:00
|
|
|
it("has its priority taken into account",
|
2019-02-12 14:21:45 +01:00
|
|
|
mock.initConverse(
|
2019-10-11 16:38:01 +02:00
|
|
|
['rosterGroupsFetched'], {},
|
2019-10-24 14:29:15 +02:00
|
|
|
async (done, _converse) => {
|
2017-07-11 10:41:11 +02:00
|
|
|
|
2019-10-24 14:29:15 +02:00
|
|
|
test_utils.openControlBox(_converse);
|
|
|
|
await test_utils.waitForRoster(_converse, 'current');
|
2019-06-03 07:58:51 +02:00
|
|
|
const contact_jid = mock.cur_names[8].replace(/ /g,'.').toLowerCase() + '@montague.lit';
|
2019-10-24 14:29:15 +02:00
|
|
|
const contact = await _converse.api.contacts.get(contact_jid);
|
2019-02-12 14:21:45 +01:00
|
|
|
let stanza = u.toStanza(`
|
|
|
|
<presence xmlns="jabber:client"
|
2019-06-03 07:58:51 +02:00
|
|
|
to="romeo@montague.lit/converse.js-21770972"
|
2019-02-12 14:21:45 +01:00
|
|
|
from="${contact_jid}/priority-1-resource">
|
|
|
|
<priority>1</priority>
|
|
|
|
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" ext="voice-v1 camera-v1 video-v1"
|
|
|
|
ver="AcN1/PEN8nq7AHD+9jpxMV4U6YM=" node="http://pidgin.im/"/>
|
|
|
|
<x xmlns="vcard-temp:x:update">
|
|
|
|
<photo>ce51d94f7f22b87a21274abb93710b9eb7cc1c65</photo>
|
|
|
|
</x>
|
|
|
|
<delay xmlns="urn:xmpp:delay" stamp="2017-02-15T20:26:05Z" from="${contact_jid}/priority-1-resource"/>
|
|
|
|
</presence>`);
|
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(contact.presence.get('show')).toBe('online');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
2017-02-20 20:47:08 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' from="'+contact_jid+'/priority-0-resource">'+
|
|
|
|
' <status/>'+
|
|
|
|
' <priority>0</priority>'+
|
|
|
|
' <show>xa</show>'+
|
|
|
|
' <c xmlns="http://jabber.org/protocol/caps" ver="GyIX/Kpa4ScVmsZCxRBboJlLAYU=" hash="sha-1"'+
|
|
|
|
' node="http://www.igniterealtime.org/projects/smack/"/>'+
|
|
|
|
' <delay xmlns="urn:xmpp:delay" stamp="2017-02-15T17:02:24Z" from="'+contact_jid+'/priority-0-resource"/>'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.get('show')).toBe('online');
|
|
|
|
|
|
|
|
expect(contact.presence.resources.length).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
2017-02-20 22:27:34 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' from="'+contact_jid+'/priority-2-resource">'+
|
|
|
|
' <priority>2</priority>'+
|
|
|
|
' <show>dnd</show>'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.get('show')).toBe('dnd');
|
|
|
|
expect(contact.presence.resources.length).toBe(3);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('priority')).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('show')).toBe('dnd');
|
2017-02-20 22:37:06 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' from="'+contact_jid+'/priority-3-resource">'+
|
|
|
|
' <priority>3</priority>'+
|
|
|
|
' <show>away</show>'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('away');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(4);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('priority')).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('show')).toBe('dnd');
|
|
|
|
expect(contact.presence.resources.get('priority-3-resource').get('priority')).toBe(3);
|
|
|
|
expect(contact.presence.resources.get('priority-3-resource').get('show')).toBe('away');
|
2017-02-20 22:37:06 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' from="'+contact_jid+'/older-priority-1-resource">'+
|
|
|
|
' <priority>1</priority>'+
|
|
|
|
' <show>dnd</show>'+
|
|
|
|
' <delay xmlns="urn:xmpp:delay" stamp="2017-02-15T15:02:24Z" from="'+contact_jid+'/older-priority-1-resource"/>'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('away');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(5);
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('show')).toBe('dnd');
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('priority')).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('show')).toBe('dnd');
|
|
|
|
expect(contact.presence.resources.get('priority-3-resource').get('priority')).toBe(3);
|
|
|
|
expect(contact.presence.resources.get('priority-3-resource').get('show')).toBe('away');
|
2017-02-20 22:37:06 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' type="unavailable"'+
|
|
|
|
' from="'+contact_jid+'/priority-3-resource">'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('dnd');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(4);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('priority')).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-2-resource').get('show')).toBe('dnd');
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('show')).toBe('dnd');
|
2017-02-20 22:27:34 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' type="unavailable"'+
|
|
|
|
' from="'+contact_jid+'/priority-2-resource">'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('online');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(3);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-1-resource').get('show')).toBe('online');
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('show')).toBe('dnd');
|
2017-02-21 22:13:49 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' type="unavailable"'+
|
|
|
|
' from="'+contact_jid+'/priority-1-resource">'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('dnd');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(2);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('priority')).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('older-priority-1-resource').get('show')).toBe('dnd');
|
2017-02-21 22:13:49 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' type="unavailable"'+
|
|
|
|
' from="'+contact_jid+'/older-priority-1-resource">'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('xa');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(1);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('priority')).toBe(0);
|
|
|
|
expect(contact.presence.resources.get('priority-0-resource').get('show')).toBe('xa');
|
2017-02-21 23:25:19 +01:00
|
|
|
|
2019-02-12 14:21:45 +01:00
|
|
|
stanza = u.toStanza(
|
2017-02-21 23:25:19 +01:00
|
|
|
'<presence xmlns="jabber:client"'+
|
2019-06-03 07:58:51 +02:00
|
|
|
' to="romeo@montague.lit/converse.js-21770972"'+
|
2017-02-21 23:25:19 +01:00
|
|
|
' type="unavailable"'+
|
|
|
|
' from="'+contact_jid+'/priority-0-resource">'+
|
|
|
|
'</presence>');
|
2019-02-12 14:21:45 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
2018-05-22 16:44:58 +02:00
|
|
|
expect(_converse.roster.get(contact_jid).presence.get('show')).toBe('offline');
|
2019-01-28 11:24:46 +01:00
|
|
|
expect(contact.presence.resources.length).toBe(0);
|
2017-07-11 10:41:11 +02:00
|
|
|
done();
|
2017-02-20 20:47:08 +01:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|