profiling.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (function (root, factory) {
  2. define([
  3. "jquery",
  4. "mock",
  5. "test_utils"
  6. ], function ($, mock, test_utils) {
  7. return factory($, mock, test_utils);
  8. }
  9. );
  10. } (this, function ($, mock, test_utils) {
  11. describe("Profiling", function() {
  12. beforeEach(function() {
  13. converse.connection.roster.items = [];
  14. converse.connection._changeConnectStatus(Strophe.Status.CONNECTED);
  15. });
  16. xit("adds hundreds of contacts to the roster", $.proxy(function() {
  17. converse.roster_groups = false;
  18. spyOn(this.roster, 'clearCache').andCallThrough();
  19. expect(this.roster.pluck('jid').length).toBe(0);
  20. var stanza = $iq({
  21. to: this.connection.jid,
  22. type: 'result',
  23. id: 'roster_1'
  24. }).c('query', {
  25. xmlns: 'jabber:iq:roster'
  26. });
  27. _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
  28. var i;
  29. for (i=0; i<100; i++) {
  30. stanza = stanza.c('item', {
  31. jid: Math.random().toString().replace('0.', '')+'@example.net',
  32. subscription:'both'
  33. }).c('group').t(group).up().up();
  34. }
  35. });
  36. this.connection.roster._onReceiveRosterSuccess(null, stanza.tree());
  37. expect(this.roster.clearCache).toHaveBeenCalled();
  38. expect(this.roster.pluck('jid').length).toBe(400);
  39. }, converse));
  40. xit("adds hundreds of contacts to the roster, with roster groups", $.proxy(function() {
  41. // converse.show_only_online_users = true;
  42. converse.roster_groups = true;
  43. spyOn(this.roster, 'clearCache').andCallThrough();
  44. expect(this.roster.pluck('jid').length).toBe(0);
  45. var stanza = $iq({
  46. to: this.connection.jid,
  47. type: 'result',
  48. id: 'roster_1'
  49. }).c('query', {
  50. xmlns: 'jabber:iq:roster'
  51. });
  52. _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
  53. var i;
  54. for (i=0; i<100; i++) {
  55. stanza = stanza.c('item', {
  56. jid: Math.random().toString().replace('0.', '')+'@example.net',
  57. subscription:'both'
  58. }).c('group').t(group).up().up();
  59. }
  60. });
  61. this.connection.roster._onReceiveRosterSuccess(null, stanza.tree());
  62. expect(this.roster.clearCache).toHaveBeenCalled();
  63. //expect(this.roster.pluck('jid').length).toBe(400);
  64. }, converse));
  65. it("contacts in a very large roster change their statuses", $.proxy(function() {
  66. }, converse));
  67. });
  68. }));