2015-01-23 16:06:10 +01:00
|
|
|
(function (root, factory) {
|
2017-04-05 11:01:31 +02:00
|
|
|
define(["mock", "converse-core", "test-utils"], factory);
|
2016-12-20 10:30:20 +01:00
|
|
|
} (this, function (mock, converse, test_utils) {
|
|
|
|
var $ = converse.env.jQuery;
|
2016-11-03 11:01:09 +01:00
|
|
|
|
|
|
|
return describe("The XMPPStatus model", function() {
|
|
|
|
|
2017-02-23 11:25:29 +01:00
|
|
|
it("won't send <show>online</show> when setting a custom status message", mock.initConverse(function (_converse) {
|
2016-12-20 10:30:20 +01:00
|
|
|
_converse.xmppstatus.save({'status': 'online'});
|
2017-04-05 11:01:31 +02:00
|
|
|
spyOn(_converse.xmppstatus, 'setStatusMessage').and.callThrough();
|
2016-12-20 10:30:20 +01:00
|
|
|
spyOn(_converse.connection, 'send');
|
|
|
|
_converse.xmppstatus.setStatusMessage("I'm also happy!");
|
2017-02-23 11:25:29 +01:00
|
|
|
expect(_converse.connection.send).toHaveBeenCalled();
|
2017-04-05 11:01:31 +02:00
|
|
|
var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
|
2017-02-23 11:25:29 +01:00
|
|
|
expect($stanza.children().length).toBe(2);
|
|
|
|
expect($stanza.children('status').length).toBe(1);
|
|
|
|
expect($stanza.children('status').text()).toBe("I'm also happy!");
|
|
|
|
expect($stanza.children('show').length).toBe(0);
|
|
|
|
expect($stanza.children('priority').length).toBe(1);
|
|
|
|
expect($stanza.children('priority').text()).toBe('0');
|
2016-11-03 11:01:09 +01:00
|
|
|
}));
|
|
|
|
});
|
2015-01-23 16:06:10 +01:00
|
|
|
}));
|