2020-09-04 12:51:03 +02:00
|
|
|
/*global mock, converse */
|
2016-11-03 11:01:09 +01:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
const u = converse.env.utils;
|
2016-11-03 11:01:09 +01:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
describe("The XMPPStatus model", function () {
|
|
|
|
|
|
|
|
it("won't send <show>online</show> when setting a custom status message",
|
2021-06-28 12:00:47 +02:00
|
|
|
mock.initConverse(async (_converse) => {
|
2021-05-12 11:07:38 +02:00
|
|
|
|
|
|
|
const sent_stanzas = _converse.connection.sent_stanzas;
|
2020-09-04 12:51:03 +02:00
|
|
|
await _converse.api.user.status.set('online');
|
2020-04-22 13:11:48 +02:00
|
|
|
_converse.api.user.status.message.set("I'm also happy!");
|
2021-05-12 11:07:38 +02:00
|
|
|
|
|
|
|
const stanza = await u.waitUntil(() => sent_stanzas.filter(s => s.matches('presence')).pop());
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(stanza.childNodes.length).toBe(3);
|
|
|
|
expect(stanza.querySelectorAll('status').length).toBe(1);
|
|
|
|
expect(stanza.querySelector('status').textContent).toBe("I'm also happy!");
|
|
|
|
expect(stanza.querySelectorAll('show').length).toBe(0);
|
|
|
|
expect(stanza.querySelectorAll('priority').length).toBe(1);
|
|
|
|
expect(stanza.querySelector('priority').textContent).toBe('0');
|
|
|
|
}));
|
2020-04-22 12:10:39 +02:00
|
|
|
});
|