xmppstatus.js 1.1 KB

123456789101112131415161718192021
  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.connection, 'send');
  8. _converse.api.user.status.message.set("I'm also happy!");
  9. expect(_converse.connection.send).toHaveBeenCalled();
  10. var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
  11. expect($stanza.children().length).toBe(2);
  12. expect($stanza.children('status').length).toBe(1);
  13. expect($stanza.children('status').text()).toBe("I'm also happy!");
  14. expect($stanza.children('show').length).toBe(0);
  15. expect($stanza.children('priority').length).toBe(1);
  16. expect($stanza.children('priority').text()).toBe('0');
  17. }));
  18. });
  19. }));