ControlBoxSpec.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. (function (root, factory) {
  2. define([
  3. "mock",
  4. "utils"
  5. ], function (mock, utils) {
  6. return factory(mock, utils);
  7. }
  8. );
  9. } (this, function (mock, utils) {
  10. describe("The Control Box", $.proxy(function (mock, utils) {
  11. window.localStorage.clear();
  12. it("is not shown by default", $.proxy(function () {
  13. expect(this.rosterview.$el.is(':visible')).toEqual(false);
  14. }, converse));
  15. var open_controlbox = $.proxy(function () {
  16. // This spec will only pass if the controlbox is not currently
  17. // open yet.
  18. expect($("div#controlbox").is(':visible')).toBe(false);
  19. spyOn(this.controlboxtoggle, 'onClick').andCallThrough();
  20. spyOn(this.controlboxtoggle, 'showControlBox').andCallThrough();
  21. // Redelegate so that the spies are now registered as the event handlers (specifically for 'onClick')
  22. this.controlboxtoggle.delegateEvents();
  23. $('.toggle-online-users').click();
  24. expect(this.controlboxtoggle.onClick).toHaveBeenCalled();
  25. expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
  26. expect($("div#controlbox").is(':visible')).toBe(true);
  27. }, converse);
  28. it("can be opened by clicking a DOM element with class 'toggle-online-users'", open_controlbox);
  29. describe("The Status Widget", $.proxy(function () {
  30. it("shows the user's chat status, which is online by default", $.proxy(function () {
  31. var view = this.xmppstatusview;
  32. expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
  33. expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe('I am online');
  34. }, converse));
  35. it("can be used to set the current user's chat status", $.proxy(function () {
  36. var view = this.xmppstatusview;
  37. spyOn(view, 'toggleOptions').andCallThrough();
  38. spyOn(view, 'setStatus').andCallThrough();
  39. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  40. runs(function () {
  41. view.$el.find('a.choose-xmpp-status').click();
  42. expect(view.toggleOptions).toHaveBeenCalled();
  43. });
  44. waits(250);
  45. runs(function () {
  46. spyOn(view, 'updateStatusUI').andCallThrough();
  47. view.initialize(); // Rebind events for spy
  48. $(view.$el.find('.dropdown dd ul li a')[1]).click();
  49. expect(view.setStatus).toHaveBeenCalled();
  50. });
  51. waits(250);
  52. runs($.proxy(function () {
  53. expect(view.updateStatusUI).toHaveBeenCalled();
  54. expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(false);
  55. expect(view.$el.find('a.choose-xmpp-status').hasClass('dnd')).toBe(true);
  56. expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe('I am busy');
  57. }, converse));
  58. }, converse));
  59. it("can be used to set a custom status message", $.proxy(function () {
  60. var view = this.xmppstatusview;
  61. this.xmppstatus.save({'status': 'online'});
  62. spyOn(view, 'setStatusMessage').andCallThrough();
  63. spyOn(view, 'renderStatusChangeForm').andCallThrough();
  64. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  65. view.$el.find('a.change-xmpp-status-message').click();
  66. expect(view.renderStatusChangeForm).toHaveBeenCalled();
  67. // The async testing here is used only to provide time for
  68. // visual feedback
  69. var msg = 'I am happy';
  70. runs (function () {
  71. view.$el.find('form input.custom-xmpp-status').val(msg);
  72. });
  73. waits(250);
  74. runs (function () {
  75. view.$el.find('form#set-custom-xmpp-status').submit();
  76. expect(view.setStatusMessage).toHaveBeenCalled();
  77. expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
  78. expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe(msg);
  79. });
  80. }, converse));
  81. }, converse));
  82. }, converse, utils, mock));
  83. describe("The Contacts Roster", $.proxy(function (utils, mock) {
  84. describe("Pending Contacts", $.proxy(function () {
  85. beforeEach(function () {
  86. if (!$("div#controlbox").is(':visible')) {
  87. $('.toggle-online-users').click();
  88. }
  89. });
  90. it("do not have a heading if there aren't any", $.proxy(function () {
  91. expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('none');
  92. }, converse));
  93. it("can be added to the roster", $.proxy(function () {
  94. spyOn(this.rosterview, 'render').andCallThrough();
  95. this.roster.create({
  96. jid: mock.pend_names[0].replace(/ /g,'.').toLowerCase() + '@localhost',
  97. subscription: 'none',
  98. ask: 'subscribe',
  99. fullname: mock.pend_names[0],
  100. is_last: true
  101. });
  102. expect(this.rosterview.$el.is(':visible')).toEqual(true);
  103. expect(this.rosterview.render).toHaveBeenCalled();
  104. }, converse));
  105. it("can be removed by the user", $.proxy(function () {
  106. var view = _.toArray(this.rosterview.rosteritemviews).pop();
  107. spyOn(window, 'confirm').andReturn(true);
  108. spyOn(this.connection.roster, 'remove').andCallThrough();
  109. spyOn(this.connection.roster, 'unauthorize');
  110. spyOn(this.rosterview.model, 'remove').andCallThrough();
  111. //spyOn(view, 'removeContact').andCallThrough();
  112. runs($.proxy(function () {
  113. view.$el.find('.remove-xmpp-contact').click();
  114. }, converse));
  115. waits(500);
  116. runs($.proxy(function () {
  117. expect(window.confirm).toHaveBeenCalled();
  118. //expect(view.removeContact).toHaveBeenCalled();
  119. expect(this.connection.roster.remove).toHaveBeenCalled();
  120. expect(this.connection.roster.unauthorize).toHaveBeenCalled();
  121. expect(this.rosterview.model.remove).toHaveBeenCalled();
  122. // The element must now be detached from the DOM.
  123. expect(view.$el.closest('html').length).toBeFalsy();
  124. }, converse));
  125. }, converse));
  126. it("will lose their own heading once the last one has been removed", $.proxy(function () {
  127. expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').is(':visible')).toBeFalsy();
  128. }, converse));
  129. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  130. var i, t, is_last;
  131. spyOn(this.rosterview, 'render').andCallThrough();
  132. for (i=0; i<mock.pend_names.length; i++) {
  133. is_last = i===(mock.pend_names.length-1);
  134. this.roster.create({
  135. jid: mock.pend_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
  136. subscription: 'none',
  137. ask: 'subscribe',
  138. fullname: mock.pend_names[i],
  139. is_last: is_last
  140. });
  141. expect(this.rosterview.render).toHaveBeenCalled();
  142. // Check that they are sorted alphabetically
  143. t = this.rosterview.$el.find('dt#pending-xmpp-contacts').siblings('dd.pending-xmpp-contact').text();
  144. expect(t).toEqual(mock.pend_names.slice(0,i+1).sort().join(''));
  145. }
  146. }, converse));
  147. it("will have their own heading once they have been added", $.proxy(function () {
  148. expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('block');
  149. }, converse));
  150. }, converse));
  151. describe("Existing Contacts", $.proxy(function () {
  152. beforeEach($.proxy(function () {
  153. utils.openControlBox();
  154. }, converse));
  155. it("do not have a heading if there aren't any", $.proxy(function () {
  156. expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('none');
  157. }, converse));
  158. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  159. var i, t;
  160. spyOn(this.rosterview, 'render').andCallThrough();
  161. for (i=0; i<mock.cur_names.length; i++) {
  162. this.roster.create({
  163. jid: mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost',
  164. subscription: 'both',
  165. ask: null,
  166. fullname: mock.cur_names[i],
  167. is_last: i===(mock.cur_names.length-1)
  168. });
  169. expect(this.rosterview.render).toHaveBeenCalled();
  170. // Check that they are sorted alphabetically
  171. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.offline').find('a.open-chat').text();
  172. expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
  173. }
  174. }, converse));
  175. it("will have their own heading once they have been added", $.proxy(function () {
  176. expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('block');
  177. }, converse));
  178. it("can change their status to online and be sorted alphabetically", $.proxy(function () {
  179. var item, view, jid, t;
  180. spyOn(this.rosterview, 'render').andCallThrough();
  181. for (i=0; i<3; i++) {
  182. jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  183. view = this.rosterview.rosteritemviews[jid];
  184. spyOn(view, 'render').andCallThrough();
  185. item = view.model;
  186. item.set('chat_status', 'online');
  187. expect(view.render).toHaveBeenCalled();
  188. expect(this.rosterview.render).toHaveBeenCalled();
  189. // Check that they are sorted alphabetically
  190. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text();
  191. expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
  192. }
  193. }, converse));
  194. it("can change their status to busy and be sorted alphabetically", $.proxy(function () {
  195. var item, view, jid, t;
  196. spyOn(this.rosterview, 'render').andCallThrough();
  197. for (i=3; i<6; i++) {
  198. jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  199. view = this.rosterview.rosteritemviews[jid];
  200. spyOn(view, 'render').andCallThrough();
  201. item = view.model;
  202. item.set('chat_status', 'dnd');
  203. expect(view.render).toHaveBeenCalled();
  204. expect(this.rosterview.render).toHaveBeenCalled();
  205. // Check that they are sorted alphabetically
  206. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text();
  207. expect(t).toEqual(mock.cur_names.slice(3,i+1).sort().join(''));
  208. }
  209. }, converse));
  210. it("can change their status to away and be sorted alphabetically", $.proxy(function () {
  211. var item, view, jid, t;
  212. spyOn(this.rosterview, 'render').andCallThrough();
  213. for (i=6; i<9; i++) {
  214. jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  215. view = this.rosterview.rosteritemviews[jid];
  216. spyOn(view, 'render').andCallThrough();
  217. item = view.model;
  218. item.set('chat_status', 'away');
  219. expect(view.render).toHaveBeenCalled();
  220. expect(this.rosterview.render).toHaveBeenCalled();
  221. // Check that they are sorted alphabetically
  222. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text();
  223. expect(t).toEqual(mock.cur_names.slice(6,i+1).sort().join(''));
  224. }
  225. }, converse));
  226. it("can change their status to xa and be sorted alphabetically", $.proxy(function () {
  227. var item, view, jid, t;
  228. spyOn(this.rosterview, 'render').andCallThrough();
  229. for (i=9; i<12; i++) {
  230. jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
  231. view = this.rosterview.rosteritemviews[jid];
  232. spyOn(view, 'render').andCallThrough();
  233. item = view.model;
  234. item.set('chat_status', 'xa');
  235. expect(view.render).toHaveBeenCalled();
  236. expect(this.rosterview.render).toHaveBeenCalled();
  237. // Check that they are sorted alphabetically
  238. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.xa').find('a.open-chat').text();
  239. expect(t).toEqual(mock.cur_names.slice(9,i+1).sort().join(''));
  240. }
  241. }, converse));
  242. it("can change their status to unavailable and be sorted alphabetically", $.proxy(function () {
  243. var item, view, jid, t;
  244. spyOn(this.rosterview, 'render').andCallThrough();
  245. for (i=12; i<15; i++) {
  246. jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
  247. view = this.rosterview.rosteritemviews[jid];
  248. spyOn(view, 'render').andCallThrough();
  249. item = view.model;
  250. item.set('chat_status', 'unavailable');
  251. expect(view.render).toHaveBeenCalled();
  252. expect(this.rosterview.render).toHaveBeenCalled();
  253. // Check that they are sorted alphabetically
  254. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text();
  255. expect(t).toEqual(mock.cur_names.slice(12, i+1).sort().join(''));
  256. }
  257. }, converse));
  258. it("are ordered according to status: online, busy, away, xa, unavailable, offline", $.proxy(function () {
  259. var contacts = this.rosterview.$el.find('dd.current-xmpp-contact');
  260. var i;
  261. for (i=0; i<3; i++) {
  262. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('online');
  263. }
  264. for (i=3; i<6; i++) {
  265. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('dnd');
  266. }
  267. for (i=6; i<9; i++) {
  268. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('away');
  269. }
  270. for (i=9; i<12; i++) {
  271. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('xa');
  272. }
  273. for (i=12; i<15; i++) {
  274. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('unavailable');
  275. }
  276. for (i=15; i<mock.cur_names.length; i++) {
  277. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('offline');
  278. }
  279. }, converse));
  280. }, converse));
  281. describe("Requesting Contacts", $.proxy(function () {
  282. // by default the dts are hidden from css class and only later they will be hidden
  283. // by jQuery therefore for the first check we will see if visible instead of none
  284. it("do not have a heading if there aren't any", $.proxy(function () {
  285. expect(this.rosterview.$el.find('dt#xmpp-contact-requests').is(':visible')).toEqual(false);
  286. }, converse));
  287. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  288. var i, t;
  289. spyOn(this.rosterview, 'render').andCallThrough();
  290. spyOn(this.controlboxtoggle, 'showControlBox').andCallThrough();
  291. for (i=0; i<mock.req_names.length; i++) {
  292. this.roster.create({
  293. jid: mock.req_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
  294. subscription: 'none',
  295. ask: 'request',
  296. fullname: mock.req_names[i],
  297. is_last: i===(mock.req_names.length-1)
  298. });
  299. expect(this.rosterview.render).toHaveBeenCalled();
  300. // Check that they are sorted alphabetically
  301. t = this.rosterview.$el.find('dt#xmpp-contact-requests').siblings('dd.requesting-xmpp-contact').text().replace(/AcceptDecline/g, '');
  302. expect(t).toEqual(mock.req_names.slice(0,i+1).sort().join(''));
  303. // When a requesting contact is added, the controlbox must
  304. // be opened.
  305. expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
  306. }
  307. }, converse));
  308. it("will have their own heading once they have been added", $.proxy(function () {
  309. expect(this.rosterview.$el.find('dt#xmpp-contact-requests').css('display')).toEqual('block');
  310. }, converse));
  311. it("can have their requests accepted by the user", $.proxy(function () {
  312. // TODO: Testing can be more thorough here, the user is
  313. // actually not accepted/authorized because of
  314. // mock_connection.
  315. var jid = mock.req_names.sort()[0].replace(' ','.').toLowerCase() + '@localhost';
  316. var view = this.rosterview.rosteritemviews[jid];
  317. spyOn(this.connection.roster, 'authorize');
  318. spyOn(view, 'acceptRequest').andCallThrough();
  319. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  320. var accept_button = view.$el.find('.accept-xmpp-request');
  321. accept_button.click();
  322. expect(view.acceptRequest).toHaveBeenCalled();
  323. expect(this.connection.roster.authorize).toHaveBeenCalled();
  324. }, converse));
  325. it("can have their requests denied by the user", $.proxy(function () {
  326. var jid = mock.req_names.sort()[1].replace(/ /g,'.').toLowerCase() + '@localhost';
  327. var view = this.rosterview.rosteritemviews[jid];
  328. spyOn(this.connection.roster, 'unauthorize');
  329. spyOn(this.rosterview, 'removeRosterItemView').andCallThrough();
  330. spyOn(view, 'declineRequest').andCallThrough();
  331. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  332. var accept_button = view.$el.find('.decline-xmpp-request');
  333. accept_button.click();
  334. expect(view.declineRequest).toHaveBeenCalled();
  335. expect(this.rosterview.removeRosterItemView).toHaveBeenCalled();
  336. expect(this.connection.roster.unauthorize).toHaveBeenCalled();
  337. // There should now be one less contact
  338. expect(this.roster.length).toEqual(mock.num_contacts-1);
  339. }, converse));
  340. }, converse));
  341. describe("All Contacts", $.proxy(function () {
  342. it("are saved to, and can be retrieved from, localStorage", $.proxy(function () {
  343. var new_attrs, old_attrs, attrs, old_roster;
  344. var num_contacts = this.roster.length;
  345. new_roster = new this.RosterItems();
  346. // Roster items are yet to be fetched from localStorage
  347. expect(new_roster.length).toEqual(0);
  348. new_roster.localStorage = new Backbone.LocalStorage(
  349. hex_sha1('converse.rosteritems-dummy@localhost'));
  350. new_roster.fetch();
  351. expect(this.roster.length).toEqual(num_contacts);
  352. // Check that the roster items retrieved from localStorage
  353. // have the same attributes values as the original ones.
  354. attrs = ['jid', 'fullname', 'subscription', 'ask'];
  355. for (i=0; i<attrs.length; i++) {
  356. new_attrs = _.pluck(_.pluck(new_roster.models, 'attributes'), attrs[i]);
  357. old_attrs = _.pluck(_.pluck(this.roster.models, 'attributes'), attrs[i]);
  358. // Roster items in storage are not necessarily sorted,
  359. // so we have to sort them here to do a proper
  360. // comparison
  361. expect(_.isEqual(new_attrs.sort(), old_attrs.sort())).toEqual(true);
  362. }
  363. this.rosterview.render();
  364. }, converse));
  365. afterEach($.proxy(function () {
  366. // Contacts retrieved from localStorage have chat_status of
  367. // "offline".
  368. // In the next test suite, we need some online contacts, so
  369. // we make some online now
  370. for (i=0; i<5; i++) {
  371. jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  372. view = this.rosterview.rosteritemviews[jid];
  373. view.model.set('chat_status', 'online');
  374. }
  375. }, converse));
  376. }, converse));
  377. }, converse, utils, mock));
  378. describe("The 'Add Contact' widget", $.proxy(function (utils, mock) {
  379. it("opens up an add form when you click on it", $.proxy(function () {
  380. var panel = this.chatboxesview.views.controlbox.contactspanel;
  381. spyOn(panel, 'toggleContactForm').andCallThrough();
  382. panel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  383. panel.$el.find('a.toggle-xmpp-contact-form').click();
  384. expect(panel.toggleContactForm).toHaveBeenCalled();
  385. // XXX: Awaiting more tests, close it again for now...
  386. panel.$el.find('a.toggle-xmpp-contact-form').click();
  387. }, converse));
  388. }, converse, utils, mock));
  389. describe("The Controlbox Tabs", $.proxy(function () {
  390. beforeEach($.proxy(function () {
  391. utils.closeAllChatBoxes();
  392. utils.openControlBox();
  393. }, converse));
  394. it("contains two tabs, 'Contacts' and 'ChatRooms'", $.proxy(function () {
  395. var cbview = this.chatboxesview.views.controlbox;
  396. var $panels = cbview.$el.find('.controlbox-panes');
  397. expect($panels.children().length).toBe(2);
  398. expect($panels.children().first().attr('id')).toBe('users');
  399. expect($panels.children().first().is(':visible')).toBe(true);
  400. expect($panels.children().last().attr('id')).toBe('chatrooms');
  401. expect($panels.children().last().is(':visible')).toBe(false);
  402. }, converse));
  403. describe("The Chatrooms Panel", $.proxy(function () {
  404. beforeEach($.proxy(function () {
  405. utils.closeAllChatBoxes();
  406. utils.openControlBox();
  407. }, converse));
  408. it("is opened by clicking the 'Chatrooms' tab", $.proxy(function () {
  409. var cbview = this.chatboxesview.views.controlbox;
  410. var $tabs = cbview.$el.find('#controlbox-tabs');
  411. var $panels = cbview.$el.find('.controlbox-panes');
  412. var $contacts = $panels.children().first();
  413. var $chatrooms = $panels.children().last();
  414. spyOn(cbview, 'switchTab').andCallThrough();
  415. cbview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  416. runs(function () {
  417. $tabs.find('li').last().find('a').click(); // Clicks the chatrooms tab
  418. });
  419. waits(250);
  420. runs(function () {
  421. expect($contacts.is(':visible')).toBe(false);
  422. expect($chatrooms.is(':visible')).toBe(true);
  423. expect(cbview.switchTab).toHaveBeenCalled();
  424. });
  425. }, converse));
  426. it("contains a form through which a new chatroom can be created", $.proxy(function () {
  427. var roomspanel = this.chatboxesview.views.controlbox.roomspanel;
  428. var $input = roomspanel.$el.find('input.new-chatroom-name');
  429. var $nick = roomspanel.$el.find('input.new-chatroom-nick');
  430. var $server = roomspanel.$el.find('input.new-chatroom-server');
  431. expect($input.length).toBe(1);
  432. expect($server.length).toBe(1);
  433. expect($('.chatroom:visible').length).toBe(0); // There shouldn't be any chatrooms open currently
  434. spyOn(roomspanel, 'createChatRoom').andCallThrough();
  435. roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  436. runs(function () {
  437. $input.val('Lounge');
  438. $nick.val('dummy');
  439. $server.val('muc.localhost');
  440. });
  441. waits('250');
  442. runs(function () {
  443. roomspanel.$el.find('form').submit();
  444. expect(roomspanel.createChatRoom).toHaveBeenCalled();
  445. });
  446. waits('250');
  447. runs($.proxy(function () {
  448. expect($('.chatroom:visible').length).toBe(1); // There should now be an open chatroom
  449. }, converse));
  450. }, converse));
  451. }, converse));
  452. }, converse, mock, utils));
  453. }));