xmppstatus.js 1.2 KB

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