MainSpec.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. (function (root, factory) {
  2. define([
  3. "converse"
  4. ], function (xmppchat) {
  5. return factory(xmppchat);
  6. }
  7. );
  8. } (this, function (xmppchat) {
  9. return describe("Converse.js", $.proxy(function() {
  10. // Names from http://www.fakenamegenerator.com/
  11. var req_names = [
  12. 'Louw Spekman', 'Mohamad Stet', 'Dominik Beyer', 'Dirk Eichel', 'Marco Duerr', 'Ute Schiffer',
  13. 'Billie Westerhuis', 'Sarah Kuester', 'Sabrina Loewe', 'Laura Duerr', 'Mathias Meyer',
  14. 'Tijm Keller', 'Lea Gerste', 'Martin Pfeffer', 'Ulrike Abt', 'Zoubida van Rooij',
  15. 'Maylin Hettema', 'Ruwan Bechan', 'Marco Beich', 'Karin Busch', 'Mathias Müller'
  16. ];
  17. var pend_names = [
  18. 'Suleyman van Beusichem', 'Nicole Diederich', 'Nanja van Yperen', 'Delany Bloemendaal',
  19. 'Jannah Hofmeester', 'Christine Trommler', 'Martin Bumgarner', 'Emil Baeten', 'Farshad Brasser',
  20. 'Gabriele Fisher', 'Sofiane Schopman', 'Sky Wismans', 'Jeffery Stoelwinder', 'Ganesh Waaijenberg',
  21. 'Dani Boldewijn', 'Katrin Propst', 'Martina Kaiser', 'Philipp Kappel', 'Meeke Grootendorst'
  22. ];
  23. var cur_names = [
  24. 'Max Frankfurter', 'Candice van der Knijff', 'Irini Vlastuin', 'Rinse Sommer', 'Annegreet Gomez',
  25. 'Robin Schook', 'Marcel Eberhardt', 'Simone Brauer', 'Asmaa Haakman', 'Felix Amsel',
  26. 'Lena Grunewald', 'Laura Grunewald', 'Mandy Seiler', 'Sven Bosch', 'Nuriye Cuypers', 'Ben Zomer',
  27. 'Leah Weiss', 'Francesca Disseldorp', 'Sven Bumgarner', 'Benjamin Zweig'
  28. ];
  29. var num_contacts = req_names.length + pend_names.length + cur_names.length;
  30. this.bare_jid = 'dummy@localhost';
  31. mock_connection = {
  32. 'muc': {
  33. 'listRooms': function () {}
  34. },
  35. 'jid': this.bare_jid,
  36. 'addHandler': function (handler, ns, name, type, id, from, options) {
  37. return function () {};
  38. },
  39. 'roster': {
  40. 'add': function () {},
  41. 'authorize': function () {},
  42. 'unauthorize': function () {},
  43. 'get': function () {},
  44. 'subscribe': function () {},
  45. 'registerCallback': function () {}
  46. },
  47. 'vcard': {
  48. 'get': function (callback, jid) {
  49. var name = jid.split('@')[0].replace('.', ' ').split(' ');
  50. var firstname = name[0].charAt(0).toUpperCase()+name[0].slice(1);
  51. var lastname = name[1].charAt(0).toUpperCase()+name[1].slice(1);
  52. var fullname = firstname+' '+lastname;
  53. var vcard = $iq().c('vCard').c('FN').t(fullname);
  54. callback(vcard.tree());
  55. }
  56. }
  57. };
  58. // Clear localStorage
  59. window.localStorage.removeItem(
  60. hex_sha1('converse.rosteritems-'+this.bare_jid));
  61. window.localStorage.removeItem(
  62. hex_sha1('converse.chatboxes-'+this.bare_jid));
  63. window.localStorage.removeItem(
  64. hex_sha1('converse.xmppstatus-'+this.bare_jid));
  65. window.localStorage.removeItem(
  66. hex_sha1('converse.messages'+cur_names[0].replace(' ','.').toLowerCase() + '@localhost'));
  67. this.prebind = true;
  68. this.onConnected(mock_connection);
  69. this.animate = false; // don't use animations
  70. // The timeout is used to slow down the tests so that one can see
  71. // visually what is happening in the page.
  72. var timeout = 0;
  73. var sleep = function (delay) {
  74. // Yes this is blocking and stupid, but these are tests and this is
  75. // the easiest way to delay execution without having to use
  76. // callbacks.
  77. var start = new Date().getTime();
  78. while (new Date().getTime() < start + delay) {
  79. continue;
  80. }
  81. };
  82. describe("The Contacts Roster", $.proxy(function () {
  83. it("is not shown by default", $.proxy(function () {
  84. expect(this.rosterview.$el.is(':visible')).toEqual(false);
  85. }, xmppchat));
  86. it("can be opened by clicking a DOM element with id 'toggle-online-users'", $.proxy(function () {
  87. spyOn(this, 'toggleControlBox').andCallThrough();
  88. $('#toggle-online-users').click();
  89. expect(this.toggleControlBox).toHaveBeenCalled();
  90. }, xmppchat));
  91. describe("Pending Contacts", $.proxy(function () {
  92. it("do not have a heading if there aren't any", $.proxy(function () {
  93. expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('none');
  94. }, xmppchat));
  95. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  96. var i, t, is_last;
  97. spyOn(this.rosterview, 'render').andCallThrough();
  98. for (i=0; i<pend_names.length; i++) {
  99. is_last = i==(pend_names.length-1);
  100. this.roster.create({
  101. jid: pend_names[i].replace(' ','.').toLowerCase() + '@localhost',
  102. subscription: 'none',
  103. ask: 'subscribe',
  104. fullname: pend_names[i],
  105. is_last: is_last
  106. });
  107. // For performance reasons, the roster should only be shown once
  108. // the last contact has been added.
  109. if (is_last) {
  110. expect(this.rosterview.$el.is(':visible')).toEqual(true);
  111. } else {
  112. expect(this.rosterview.$el.is(':visible')).toEqual(false);
  113. }
  114. expect(this.rosterview.render).toHaveBeenCalled();
  115. // Check that they are sorted alphabetically
  116. t = this.rosterview.$el.find('dt#pending-xmpp-contacts').siblings('dd.pending-xmpp-contact').text();
  117. expect(t).toEqual(pend_names.slice(0,i+1).sort().join(''));
  118. }
  119. sleep(timeout);
  120. }, xmppchat));
  121. it("will have their own heading once they have been added", $.proxy(function () {
  122. expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('block');
  123. }, xmppchat));
  124. }, xmppchat));
  125. describe("Existing Contacts", $.proxy(function () {
  126. it("do not have a heading if there aren't any", $.proxy(function () {
  127. expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('none');
  128. }, xmppchat));
  129. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  130. var i, t;
  131. spyOn(this.rosterview, 'render').andCallThrough();
  132. for (i=0; i<cur_names.length; i++) {
  133. this.roster.create({
  134. jid: cur_names[i].replace(' ','.').toLowerCase() + '@localhost',
  135. subscription: 'both',
  136. ask: null,
  137. fullname: cur_names[i],
  138. is_last: i==(cur_names.length-1)
  139. });
  140. expect(this.rosterview.render).toHaveBeenCalled();
  141. // Check that they are sorted alphabetically
  142. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.offline').find('a.open-chat').text();
  143. expect(t).toEqual(cur_names.slice(0,i+1).sort().join(''));
  144. }
  145. sleep(timeout);
  146. }, xmppchat));
  147. it("will have their own heading once they have been added", $.proxy(function () {
  148. expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('block');
  149. }, xmppchat));
  150. it("can change their status to online and be sorted alphabetically", $.proxy(function () {
  151. var item, view, jid, t;
  152. spyOn(this.rosterview, 'render').andCallThrough();
  153. for (i=0; i<5; i++) {
  154. jid = cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  155. view = this.rosterview.rosteritemviews[jid];
  156. spyOn(view, 'render').andCallThrough();
  157. item = view.model;
  158. item.set('chat_status', 'online');
  159. expect(view.render).toHaveBeenCalled();
  160. expect(this.rosterview.render).toHaveBeenCalled();
  161. // Check that they are sorted alphabetically
  162. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text();
  163. expect(t).toEqual(cur_names.slice(0,i+1).sort().join(''));
  164. sleep(timeout);
  165. }
  166. }, xmppchat));
  167. it("can change their status to busy and be sorted alphabetically", $.proxy(function () {
  168. var item, view, jid, t;
  169. spyOn(this.rosterview, 'render').andCallThrough();
  170. for (i=5; i<10; i++) {
  171. jid = cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  172. view = this.rosterview.rosteritemviews[jid];
  173. spyOn(view, 'render').andCallThrough();
  174. item = view.model;
  175. item.set('chat_status', 'dnd');
  176. expect(view.render).toHaveBeenCalled();
  177. expect(this.rosterview.render).toHaveBeenCalled();
  178. // Check that they are sorted alphabetically
  179. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text();
  180. expect(t).toEqual(cur_names.slice(5,i+1).sort().join(''));
  181. sleep(timeout);
  182. }
  183. }, xmppchat));
  184. it("can change their status to away and be sorted alphabetically", $.proxy(function () {
  185. var item, view, jid, t;
  186. spyOn(this.rosterview, 'render').andCallThrough();
  187. for (i=10; i<15; i++) {
  188. jid = cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  189. view = this.rosterview.rosteritemviews[jid];
  190. spyOn(view, 'render').andCallThrough();
  191. item = view.model;
  192. item.set('chat_status', 'away');
  193. expect(view.render).toHaveBeenCalled();
  194. expect(this.rosterview.render).toHaveBeenCalled();
  195. // Check that they are sorted alphabetically
  196. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text();
  197. expect(t).toEqual(cur_names.slice(10,i+1).sort().join(''));
  198. sleep(timeout);
  199. }
  200. }, xmppchat));
  201. it("can change their status to unavailable and be sorted alphabetically", $.proxy(function () {
  202. var item, view, jid, t;
  203. spyOn(this.rosterview, 'render').andCallThrough();
  204. for (i=15; i<20; i++) {
  205. jid = cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  206. view = this.rosterview.rosteritemviews[jid];
  207. spyOn(view, 'render').andCallThrough();
  208. item = view.model;
  209. item.set('chat_status', 'unavailable');
  210. expect(view.render).toHaveBeenCalled();
  211. expect(this.rosterview.render).toHaveBeenCalled();
  212. // Check that they are sorted alphabetically
  213. t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text();
  214. expect(t).toEqual(cur_names.slice(15, i+1).sort().join(''));
  215. sleep(timeout);
  216. }
  217. }, xmppchat));
  218. it("are ordered according to status: online, busy, away, unavailable, offline", $.proxy(function () {
  219. var contacts = this.rosterview.$el.find('dd.current-xmpp-contact');
  220. var i;
  221. // The first five contacts are online.
  222. for (i=0; i<5; i++) {
  223. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('online');
  224. }
  225. // The next five are busy
  226. for (i=5; i<10; i++) {
  227. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('dnd');
  228. }
  229. // The next five are away
  230. for (i=10; i<15; i++) {
  231. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('away');
  232. }
  233. // The next five are unavailable
  234. for (i=15; i<20; i++) {
  235. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('unavailable');
  236. }
  237. // The next 20 are offline
  238. for (i=20; i<cur_names.length; i++) {
  239. expect($(contacts[i]).attr('class').split(' ',1)[0]).toEqual('offline');
  240. }
  241. }, xmppchat));
  242. }, xmppchat));
  243. describe("Requesting Contacts", $.proxy(function () {
  244. // by default the dts are hidden from css class and only later they will be hidden
  245. // by jQuery therefore for the first check we will see if visible instead of none
  246. it("do not have a heading if there aren't any", $.proxy(function () {
  247. expect(this.rosterview.$el.find('dt#xmpp-contact-requests').is(':visible')).toEqual(false);
  248. }, xmppchat));
  249. it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
  250. var i, t;
  251. spyOn(this.rosterview, 'render').andCallThrough();
  252. spyOn(this, 'showControlBox').andCallThrough();
  253. for (i=0; i<req_names.length; i++) {
  254. this.roster.create({
  255. jid: req_names[i].replace(' ','.').toLowerCase() + '@localhost',
  256. subscription: 'none',
  257. ask: 'request',
  258. fullname: req_names[i],
  259. is_last: i==(req_names.length-1)
  260. });
  261. expect(this.rosterview.render).toHaveBeenCalled();
  262. // Check that they are sorted alphabetically
  263. t = this.rosterview.$el.find('dt#xmpp-contact-requests').siblings('dd.requesting-xmpp-contact').text().replace(/AcceptDecline/g, '');
  264. expect(t).toEqual(req_names.slice(0,i+1).sort().join(''));
  265. // When a requesting contact is added, the controlbox must
  266. // be opened.
  267. expect(this.showControlBox).toHaveBeenCalled();
  268. }
  269. sleep(timeout);
  270. }, xmppchat));
  271. it("will have their own heading once they have been added", $.proxy(function () {
  272. expect(this.rosterview.$el.find('dt#xmpp-contact-requests').css('display')).toEqual('block');
  273. }, xmppchat));
  274. it("can have their requests accepted by the user", $.proxy(function () {
  275. // TODO: Testing can be more thorough here, the user is
  276. // actually not accepted/authorized because of
  277. // mock_connection.
  278. var jid = req_names.sort()[0].replace(' ','.').toLowerCase() + '@localhost';
  279. var view = this.rosterview.rosteritemviews[jid];
  280. spyOn(this.connection.roster, 'authorize');
  281. spyOn(view, 'acceptRequest').andCallThrough();
  282. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  283. var accept_button = view.$el.find('.accept-xmpp-request');
  284. accept_button.click();
  285. expect(view.acceptRequest).toHaveBeenCalled();
  286. expect(this.connection.roster.authorize).toHaveBeenCalled();
  287. sleep(timeout);
  288. }, xmppchat));
  289. it("can have their requests denied by the user", $.proxy(function () {
  290. var jid = req_names.sort()[1].replace(' ','.').toLowerCase() + '@localhost';
  291. var view = this.rosterview.rosteritemviews[jid];
  292. spyOn(this.connection.roster, 'unauthorize');
  293. spyOn(this.rosterview, 'removeRosterItem').andCallThrough();
  294. spyOn(view, 'declineRequest').andCallThrough();
  295. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  296. var accept_button = view.$el.find('.decline-xmpp-request');
  297. accept_button.click();
  298. expect(view.declineRequest).toHaveBeenCalled();
  299. expect(this.rosterview.removeRosterItem).toHaveBeenCalled();
  300. expect(this.connection.roster.unauthorize).toHaveBeenCalled();
  301. // There should now be one less contact
  302. expect(this.roster.length).toEqual(num_contacts-1);
  303. sleep(timeout);
  304. }, xmppchat));
  305. }, xmppchat));
  306. describe("All Contacts", $.proxy(function () {
  307. it("are saved to, and can be retrieved from, localStorage", $.proxy(function () {
  308. var new_attrs, old_attrs, attrs, old_roster;
  309. // One contact was declined, so we have 1 less contact then originally
  310. expect(this.roster.length).toEqual(num_contacts-1);
  311. old_roster = this.roster;
  312. this.roster = new this.RosterItems();
  313. expect(this.roster.length).toEqual(0);
  314. this.roster.localStorage = new Backbone.LocalStorage(
  315. hex_sha1('converse.rosteritems-dummy@localhost'));
  316. this.chatboxes.onConnected();
  317. spyOn(this.roster, 'fetch').andCallThrough();
  318. this.rosterview = new this.RosterView({'model':this.roster});
  319. expect(this.roster.fetch).toHaveBeenCalled();
  320. expect(this.roster.length).toEqual(num_contacts-1);
  321. // Check that the roster items retrieved from localStorage
  322. // have the same attributes values as the original ones.
  323. attrs = ['jid', 'fullname', 'subscription', 'ask'];
  324. for (i=0; i<attrs.length; i++) {
  325. new_attrs = _.pluck(_.pluck(this.roster.models, 'attributes'), attrs[i]);
  326. old_attrs = _.pluck(_.pluck(old_roster.models, 'attributes'), attrs[i]);
  327. // Roster items in storage are not necessarily sorted,
  328. // so we have to sort them here to do a proper
  329. // comparison
  330. expect(_.isEqual(new_attrs.sort(), old_attrs.sort())).toEqual(true);
  331. }
  332. this.rosterview.render();
  333. }, xmppchat));
  334. afterEach($.proxy(function () {
  335. // Contacts retrieved from localStorage have chat_status of
  336. // "offline".
  337. // In the next test suite, we need some online contacts, so
  338. // we make some online now
  339. for (i=0; i<5; i++) {
  340. jid = cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
  341. view = this.rosterview.rosteritemviews[jid];
  342. view.model.set('chat_status', 'online');
  343. }
  344. }, xmppchat));
  345. }, xmppchat));
  346. }, xmppchat));
  347. describe("A Chatbox", $.proxy(function () {
  348. it("is created when you click on a roster item", $.proxy(function () {
  349. var i, $el, click, jid, view;
  350. // showControlBox was called earlier, so the controlbox is
  351. // visible, but no other chat boxes have been created.
  352. expect(this.chatboxes.length).toEqual(1);
  353. var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat');
  354. for (i=0; i<online_contacts.length; i++) {
  355. $el = $(online_contacts[i]);
  356. jid = $el.text().replace(' ','.').toLowerCase() + '@localhost';
  357. view = this.rosterview.rosteritemviews[jid];
  358. spyOn(view, 'openChat').andCallThrough();
  359. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  360. $el.click();
  361. expect(view.openChat).toHaveBeenCalled();
  362. expect(this.chatboxes.length).toEqual(i+2);
  363. sleep(timeout);
  364. }
  365. }, xmppchat));
  366. it("can be saved to, and retrieved from, localStorage", $.proxy(function () {
  367. // We instantiate a new ChatBoxes collection, which by default
  368. // will be empty.
  369. this.newchatboxes = new this.ChatBoxes();
  370. expect(this.newchatboxes.length).toEqual(0);
  371. // The chatboxes will then be fetched from localStorage inside the
  372. // onConnected method
  373. this.newchatboxes.onConnected();
  374. expect(this.newchatboxes.length).toEqual(6);
  375. // Check that the roster items retrieved from localStorage
  376. // have the same attributes values as the original ones.
  377. attrs = ['id', 'box_id', 'visible'];
  378. for (i=0; i<attrs.length; i++) {
  379. new_attrs = _.pluck(_.pluck(this.newchatboxes.models, 'attributes'), attrs[i]);
  380. old_attrs = _.pluck(_.pluck(this.chatboxes.models, 'attributes'), attrs[i]);
  381. expect(_.isEqual(new_attrs, old_attrs)).toEqual(true);
  382. }
  383. this.rosterview.render();
  384. }, xmppchat));
  385. it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
  386. var chatbox, view, $el,
  387. num_open_chats = this.chatboxes.length;
  388. for (i=0; i<num_open_chats; i++) {
  389. chatbox = this.chatboxes.models[0];
  390. view = this.chatboxesview.views[chatbox.get('id')];
  391. spyOn(view, 'closeChat').andCallThrough();
  392. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
  393. view.$el.find('.close-chatbox-button').click();
  394. expect(view.closeChat).toHaveBeenCalled();
  395. sleep(timeout);
  396. }
  397. }, xmppchat));
  398. it("will be removed from localStorage when closed", $.proxy(function () {
  399. this.newchatboxes = new this.ChatBoxes();
  400. expect(this.newchatboxes.length).toEqual(0);
  401. // onConnected will fetch chatboxes in localStorage, but
  402. // because there aren't any open chatboxes, there won't be any
  403. // in localStorage either.
  404. this.chatboxes.onConnected();
  405. expect(this.chatboxes.length).toEqual(0);
  406. }, xmppchat));
  407. describe("A Chat Message", $.proxy(function () {
  408. it("can be received which will open a chatbox and be displayed inside it", $.proxy(function () {
  409. var message = 'This is a received message';
  410. var sender_jid = cur_names[0].replace(' ','.').toLowerCase() + '@localhost';
  411. msg = $msg({
  412. from: sender_jid,
  413. to: this.bare_jid,
  414. type: 'chat',
  415. id: (new Date()).getTime()
  416. }).c('body').t(message).up()
  417. .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
  418. spyOn(this, 'getVCard').andCallThrough();
  419. // We don't already have an open chatbox for this user
  420. expect(this.chatboxes.get(sender_jid)).not.toBeDefined();
  421. runs($.proxy(function () {
  422. // messageReceived is a handler for received XMPP
  423. // messages
  424. this.chatboxes.messageReceived(msg);
  425. }, xmppchat));
  426. waits(500);
  427. runs($.proxy(function () {
  428. // Since we didn't already have an open chatbox, one
  429. // will asynchronously created inside a callback to
  430. // getVCard
  431. expect(this.getVCard).toHaveBeenCalled();
  432. // Check that the chatbox and its view now exist
  433. var chatbox = this.chatboxes.get(sender_jid);
  434. var chatboxview = this.chatboxesview.views[sender_jid];
  435. expect(chatbox).toBeDefined();
  436. expect(chatboxview).toBeDefined();
  437. // Check that the message was received and check the
  438. // message parameters
  439. expect(chatbox.messages.length).toEqual(1);
  440. var msg_obj = chatbox.messages.models[0];
  441. expect(msg_obj.get('message')).toEqual(message);
  442. // XXX: This is stupid, fullname is actually only the
  443. // users first name
  444. expect(msg_obj.get('fullname')).toEqual(cur_names[0].split(' ')[0]);
  445. expect(msg_obj.get('sender')).toEqual('them');
  446. expect(msg_obj.get('delayed')).toEqual(false);
  447. // Now check that the message appears inside the
  448. // chatbox in the DOM
  449. var txt = chatboxview.$el.find('.chat-content').find('.chat-message').find('.chat-message-content').text();
  450. expect(txt).toEqual(message);
  451. }, xmppchat));
  452. }, xmppchat));
  453. it("can be sent from a chatbox, and will appear inside it", $.proxy(function () {
  454. // TODO
  455. }, xmppchat));
  456. }, xmppchat));
  457. }, xmppchat));
  458. }, xmppchat));
  459. }));