xmppstatus.js 1.2 KB

1234567891011121314151617181920212223
  1. (function (root, factory) {
  2. define(["mock", "converse-core", "test-utils"], factory);
  3. } (this, function (mock, converse, test_utils) {
  4. var $ = converse.env.jQuery;
  5. return describe("The XMPPStatus model", function() {
  6. it("won't send <show>online</show> when setting a custom status message", mock.initConverse(function (_converse) {
  7. _converse.xmppstatus.save({'status': 'online'});
  8. spyOn(_converse.xmppstatus, 'setStatusMessage').and.callThrough();
  9. spyOn(_converse.connection, 'send');
  10. _converse.xmppstatus.setStatusMessage("I'm also happy!");
  11. expect(_converse.connection.send).toHaveBeenCalled();
  12. var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
  13. expect($stanza.children().length).toBe(2);
  14. expect($stanza.children('status').length).toBe(1);
  15. expect($stanza.children('status').text()).toBe("I'm also happy!");
  16. expect($stanza.children('show').length).toBe(0);
  17. expect($stanza.children('priority').length).toBe(1);
  18. expect($stanza.children('priority').text()).toBe('0');
  19. }));
  20. });
  21. }));