pusher-js 7.0.0 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.github/stale.yml +26 -0
  2. package/.github/workflows/release.yml +112 -0
  3. package/.github/workflows/release_pr.yml +42 -0
  4. package/.github/workflows/run-tests.yml +38 -0
  5. package/.vscode/settings.json +31 -0
  6. package/CHANGELOG.md +29 -0
  7. package/Makefile +17 -12
  8. package/README.md +28 -0
  9. package/dist/node/pusher.js +87 -45
  10. package/dist/node/pusher.js.map +1 -0
  11. package/dist/react-native/pusher.js +3 -2
  12. package/dist/react-native/pusher.js.map +1 -0
  13. package/dist/web/pusher-with-encryption.js +9 -6
  14. package/dist/web/pusher-with-encryption.js.map +1 -0
  15. package/dist/web/pusher-with-encryption.min.js +3 -2
  16. package/dist/web/pusher-with-encryption.min.js.map +1 -0
  17. package/dist/web/pusher.js +9 -6
  18. package/dist/web/pusher.js.map +1 -0
  19. package/dist/web/pusher.min.js +3 -2
  20. package/dist/web/pusher.min.js.map +1 -0
  21. package/dist/worker/pusher-with-encryption.worker.js +9 -6
  22. package/dist/worker/pusher-with-encryption.worker.js.map +1 -0
  23. package/dist/worker/pusher-with-encryption.worker.min.js +3 -2
  24. package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -0
  25. package/dist/worker/pusher.worker.js +9 -6
  26. package/dist/worker/pusher.worker.js.map +1 -0
  27. package/dist/worker/pusher.worker.min.js +3 -2
  28. package/dist/worker/pusher.worker.min.js.map +1 -0
  29. package/package.json +17 -15
  30. package/react-native/index.d.ts +7 -8
  31. package/spec/config/jasmine/helpers/reporter.js +14 -0
  32. package/spec/config/jasmine/integration.json +13 -0
  33. package/spec/config/jasmine/unit.json +13 -0
  34. package/spec/config/{jasmine-node → jasmine}/webpack.integration.js +4 -4
  35. package/spec/config/{jasmine-node → jasmine}/webpack.unit.js +4 -6
  36. package/spec/config/karma/config.common.js +10 -4
  37. package/spec/config/karma/config.integration.js +4 -4
  38. package/spec/config/karma/config.unit.js +5 -7
  39. package/spec/config/karma/integration.js +3 -3
  40. package/spec/config/karma/unit.js +2 -2
  41. package/spec/javascripts/helpers/mocks.js +18 -18
  42. package/spec/javascripts/helpers/waitsFor.js +37 -0
  43. package/spec/javascripts/integration/core/cluster_config_spec.js +45 -34
  44. package/spec/javascripts/integration/core/falling_back_spec.js +124 -127
  45. package/spec/javascripts/integration/core/pusher_spec/test_builder.js +264 -284
  46. package/spec/javascripts/integration/core/timeout_configuration_spec.js +24 -22
  47. package/spec/javascripts/integration/core/transport_lists_spec.js +8 -8
  48. package/spec/javascripts/integration/web/dom/jsonp_spec.js +67 -69
  49. package/spec/javascripts/integration/web/dom/script_request_spec.js +44 -52
  50. package/spec/javascripts/unit/core/channels/channel_spec.js +32 -19
  51. package/spec/javascripts/unit/core/channels/encrypted_channel_spec.js +9 -17
  52. package/spec/javascripts/unit/core/channels/presence_channel_spec.js +8 -19
  53. package/spec/javascripts/unit/core/channels/private_channel_spec.js +9 -19
  54. package/spec/javascripts/unit/core/config_spec.js +2 -2
  55. package/spec/javascripts/unit/core/connection/connection_manager_spec.js +69 -63
  56. package/spec/javascripts/unit/core/connection/connection_spec.js +14 -13
  57. package/spec/javascripts/unit/core/connection/handshake_spec.js +14 -12
  58. package/spec/javascripts/unit/core/connection/protocol_spec.js +9 -4
  59. package/spec/javascripts/unit/core/defaults_spec.js +1 -1
  60. package/spec/javascripts/unit/core/events_dispatcher_spec.js +20 -20
  61. package/spec/javascripts/unit/core/http/http_polling_socket_spec.js +4 -4
  62. package/spec/javascripts/unit/core/http/http_request_spec.js +20 -17
  63. package/spec/javascripts/unit/core/http/http_socket_spec.js +35 -32
  64. package/spec/javascripts/unit/core/http/http_streaming_socket_spec.js +4 -4
  65. package/spec/javascripts/unit/core/http/http_xhr_request_spec.js +13 -13
  66. package/spec/javascripts/unit/core/pusher_authorizer_spec.js +11 -11
  67. package/spec/javascripts/unit/core/pusher_spec.js +41 -27
  68. package/spec/javascripts/unit/core/strategies/best_connected_ever_strategy_spec.js +5 -5
  69. package/spec/javascripts/unit/core/strategies/cached_strategy_spec.js +17 -13
  70. package/spec/javascripts/unit/core/strategies/delayed_strategy_spec.js +12 -8
  71. package/spec/javascripts/unit/core/strategies/sequential_strategy_spec.js +23 -19
  72. package/spec/javascripts/unit/core/strategies/transport_strategy_spec.js +22 -24
  73. package/spec/javascripts/unit/core/timeline/timeline_spec.js +16 -9
  74. package/spec/javascripts/unit/core/transports/assistant_to_the_transport_manager_spec.js +36 -22
  75. package/spec/javascripts/unit/core/transports/hosts_and_ports_spec.js +10 -10
  76. package/spec/javascripts/unit/core/transports/transport_connection_spec.js +81 -86
  77. package/spec/javascripts/unit/core/transports/transport_manager_spec.js +1 -1
  78. package/spec/javascripts/unit/core/utils/periodic_timer_spec.js +17 -16
  79. package/spec/javascripts/unit/core/utils/timers_spec.js +32 -26
  80. package/spec/javascripts/unit/isomorphic/transports/hosts_and_ports_spec.js +12 -8
  81. package/spec/javascripts/unit/isomorphic/transports/transports_spec.js +7 -7
  82. package/spec/javascripts/unit/node/timeline_sender_spec.js +5 -5
  83. package/spec/javascripts/unit/web/dom/dependency_loader_spec.js +30 -30
  84. package/spec/javascripts/unit/web/dom/jsonp_request_spec.js +7 -7
  85. package/spec/javascripts/unit/web/http/http_xdomain_request_spec.js +22 -22
  86. package/spec/javascripts/unit/web/pusher_authorizer_spec.js +3 -3
  87. package/spec/javascripts/unit/web/timeline/timeline_sender_spec.js +12 -12
  88. package/spec/javascripts/unit/web/transports/hosts_and_ports_spec.js +15 -12
  89. package/spec/javascripts/unit/web/transports/transports_spec.js +24 -26
  90. package/spec/javascripts/unit/worker/pusher_authorizer_spec.js +2 -2
  91. package/spec/javascripts/unit/worker/timeline_sender_spec.js +2 -2
  92. package/src/core/auth/options.ts +1 -0
  93. package/src/core/channels/channel.ts +1 -0
  94. package/src/core/pusher.ts +1 -1
  95. package/tags +393 -0
  96. package/types/src/core/auth/options.d.ts +1 -0
  97. package/webpack/config.node.js +2 -2
  98. package/webpack/config.react-native.js +2 -2
  99. package/webpack/config.shared.js +9 -1
  100. package/webpack/config.web.js +2 -2
  101. package/webpack/config.worker.js +2 -2
  102. package/with-encryption/index.d.ts +0 -1
  103. package/worker/index.d.ts +15 -0
  104. package/worker/index.js +1 -0
  105. package/worker/with-encryption/index.d.ts +15 -0
  106. package/worker/with-encryption/index.js +1 -0
  107. package/.travis.build +0 -22
  108. package/.travis.yml +0 -7
  109. package/spec/config/jasmine-node/config.js +0 -10
@@ -10,9 +10,9 @@ describe("HTTP.getXHR", function() {
10
10
  beforeEach(function() {
11
11
  HTTPFactory = require('runtime').default.HTTPFactory;
12
12
 
13
- spyOn(Runtime, 'getXHRAPI').andReturn(Mocks.getXHR);
13
+ spyOn(Runtime, 'getXHRAPI').and.returnValue(Mocks.getXHR);
14
14
 
15
- spyOn(HTTPFactory, "createRequest").andCallFake(function(h, m, u) {
15
+ spyOn(HTTPFactory, "createRequest").and.callFake(function(h, m, u) {
16
16
  hooks = h;
17
17
  return Mocks.getHTTPRequest(m, u);
18
18
  });
@@ -64,7 +64,7 @@ describe("HTTP.getXHR", function() {
64
64
  xhr.responseText = "asdf";
65
65
 
66
66
  xhr.onreadystatechange();
67
- expect(socket.onChunk.calls.length).toEqual(1);
67
+ expect(socket.onChunk.calls.count()).toEqual(1);
68
68
  expect(socket.onChunk).toHaveBeenCalledWith(201, "asdf");
69
69
  });
70
70
 
@@ -73,12 +73,12 @@ describe("HTTP.getXHR", function() {
73
73
  xhr.responseText = "asdf";
74
74
 
75
75
  xhr.onreadystatechange();
76
- expect(socket.onChunk.calls.length).toEqual(1);
76
+ expect(socket.onChunk.calls.count()).toEqual(1);
77
77
  expect(socket.onChunk).toHaveBeenCalledWith(201, "asdf");
78
78
 
79
79
  xhr.responseText = "asdfghjkl";
80
80
  xhr.onreadystatechange();
81
- expect(socket.onChunk.calls.length).toEqual(2);
81
+ expect(socket.onChunk.calls.count()).toEqual(2);
82
82
  expect(socket.onChunk).toHaveBeenCalledWith(201, "asdfghjkl");
83
83
  });
84
84
  });
@@ -93,7 +93,7 @@ describe("HTTP.getXHR", function() {
93
93
  xhr.responseText = "";
94
94
 
95
95
  xhr.onreadystatechange();
96
- expect(socket.close.calls.length).toEqual(1);
96
+ expect(socket.close.calls.count()).toEqual(1);
97
97
  });
98
98
 
99
99
  it("should not call socket.onChunk if there is no responseText", function() {
@@ -116,8 +116,8 @@ describe("HTTP.getXHR", function() {
116
116
  xhr.status = 234;
117
117
  xhr.responseText = "12356890";
118
118
 
119
- socket.close.andCallFake(function() {
120
- expect(socket.onChunk.calls.length).toEqual(1);
119
+ socket.close.and.callFake(function() {
120
+ expect(socket.onChunk.calls.count()).toEqual(1);
121
121
  expect(socket.onChunk).toHaveBeenCalledWith(234, "12356890");
122
122
  });
123
123
 
@@ -131,8 +131,8 @@ describe("HTTP.getXHR", function() {
131
131
  var onFinished = jasmine.createSpy();
132
132
  socket.bind("finished", onFinished);
133
133
 
134
- socket.close.andCallFake(function() {
135
- expect(onFinished.calls.length).toEqual(1);
134
+ socket.close.and.callFake(function() {
135
+ expect(onFinished.calls.count()).toEqual(1);
136
136
  expect(onFinished).toHaveBeenCalledWith(404);
137
137
  });
138
138
 
@@ -145,15 +145,15 @@ describe("HTTP.getXHR", function() {
145
145
  it("should abort the passed request", function() {
146
146
  var xhr = Mocks.getXHR();
147
147
 
148
- expect(xhr.abort.calls.length).toEqual(0);
148
+ expect(xhr.abort.calls.count()).toEqual(0);
149
149
  hooks.abortRequest(xhr);
150
- expect(xhr.abort.calls.length).toEqual(1);
150
+ expect(xhr.abort.calls.count()).toEqual(1);
151
151
  });
152
152
 
153
153
  it("should set the onreadystatechange listener to null before calling abort", function() {
154
154
  var xhr = Mocks.getXHR();
155
155
  xhr.onreadystatechange = function() {};
156
- xhr.abort.andCallFake(function() {
156
+ xhr.abort.and.callFake(function() {
157
157
  expect(xhr.onreadystatechange).toBe(null);
158
158
  });
159
159
 
@@ -52,9 +52,9 @@ if (TestEnv !== "worker") {
52
52
  xhr = new Mocks.getXHR();
53
53
 
54
54
  if (TestEnv === "web" && !window.XMLHttpRequest) {
55
- spyOn(Runtime, "createMicrosoftXHR").andReturn(xhr);
55
+ spyOn(Runtime, "createMicrosoftXHR").and.returnValue(xhr);
56
56
  } else {
57
- spyOn(Runtime, "createXHR").andReturn(xhr);
57
+ spyOn(Runtime, "createXHR").and.returnValue(xhr);
58
58
  }
59
59
  });
60
60
 
@@ -70,7 +70,7 @@ if (TestEnv !== "worker") {
70
70
  );
71
71
  authorizer.authorize("1.23", function() {});
72
72
 
73
- expect(xhr.setRequestHeader.calls.length).toEqual(3);
73
+ expect(xhr.setRequestHeader.calls.count()).toEqual(3);
74
74
  expect(xhr.setRequestHeader).toHaveBeenCalledWith(
75
75
  "Content-Type", "application/x-www-form-urlencoded"
76
76
  );
@@ -90,7 +90,7 @@ if (TestEnv !== "worker") {
90
90
  );
91
91
  authorizer.authorize("1.23", function() {});
92
92
 
93
- expect(xhr.send.calls.length).toEqual(1);
93
+ expect(xhr.send.calls.count()).toEqual(1);
94
94
  expect(xhr.send).toHaveBeenCalledWith(
95
95
  "socket_id=1.23&channel_name=chan&a=1&b=2"
96
96
  );
@@ -109,9 +109,9 @@ if (TestEnv !== "worker") {
109
109
  authorizer.authorize("1.23", callback);
110
110
 
111
111
  if (TestEnv === "web" && !window.XMLHttpRequest) {
112
- expect(Runtime.createMicrosoftXHR.calls.length).toEqual(1);
112
+ expect(Runtime.createMicrosoftXHR.calls.count()).toEqual(1);
113
113
  } else {
114
- expect(Runtime.createXHR.calls.length).toEqual(1);
114
+ expect(Runtime.createXHR.calls.count()).toEqual(1);
115
115
  }
116
116
 
117
117
  xhr.readyState = 4;
@@ -119,7 +119,7 @@ if (TestEnv !== "worker") {
119
119
  xhr.responseText = dataJSON;
120
120
  xhr.onreadystatechange();
121
121
 
122
- expect(callback.calls.length).toEqual(1);
122
+ expect(callback.calls.count()).toEqual(1);
123
123
  expect(callback).toHaveBeenCalledWith(null, data);
124
124
  });
125
125
 
@@ -133,9 +133,9 @@ if (TestEnv !== "worker") {
133
133
  authorizer.authorize("1.23", callback);
134
134
 
135
135
  if (TestEnv === "web" && !window.XMLHttpRequest) {
136
- expect(Runtime.createMicrosoftXHR.calls.length).toEqual(1);
136
+ expect(Runtime.createMicrosoftXHR.calls.count()).toEqual(1);
137
137
  } else {
138
- expect(Runtime.createXHR.calls.length).toEqual(1);
138
+ expect(Runtime.createXHR.calls.count()).toEqual(1);
139
139
  }
140
140
 
141
141
  xhr.readyState = 4;
@@ -143,10 +143,10 @@ if (TestEnv !== "worker") {
143
143
  xhr.responseText = invalidJSON;
144
144
  xhr.onreadystatechange();
145
145
 
146
- expect(callback.calls.length).toEqual(1);
146
+ expect(callback.calls.count()).toEqual(1);
147
147
  // For some reason comparing the Error types doesn't work properly in
148
148
  // Safari on Mojave. Manually check the arguments.
149
- let args = callback.calls[0].args;
149
+ let args = callback.calls.first().args;
150
150
  expect(args.length).toEqual(2)
151
151
  expect(args[0]).toEqual(jasmine.any(Error))
152
152
  expect(args[0].message).toEqual(
@@ -32,23 +32,23 @@ describe("Pusher", function() {
32
32
  Pusher.isReady = false;
33
33
  Pusher.instances = [];
34
34
 
35
- spyOn(Runtime, "getDefaultStrategy").andCallFake(function() {
35
+ spyOn(Runtime, "getDefaultStrategy").and.callFake(function() {
36
36
  return Mocks.getStrategy(true);
37
37
  });
38
38
 
39
- spyOn(Factory, "createConnectionManager").andCallFake(function(key, options, config) {
39
+ spyOn(Factory, "createConnectionManager").and.callFake(function(key, options, config) {
40
40
  var manager = Mocks.getConnectionManager();
41
41
  manager.key = key;
42
42
  manager.options = options;
43
43
  manager.config = config;
44
44
  return manager;
45
45
  });
46
- spyOn(Factory, "createChannel").andCallFake(function(name, _) {
46
+ spyOn(Factory, "createChannel").and.callFake(function(name, _) {
47
47
  return Mocks.getChannel(name);
48
48
  });
49
49
 
50
50
  if (TestEnv === "web") {
51
- spyOn(Runtime, "getDocument").andReturn({
51
+ spyOn(Runtime, "getDocument").and.returnValue({
52
52
  location: {
53
53
  protocol: "http:"
54
54
  }
@@ -116,7 +116,7 @@ describe("Pusher", function() {
116
116
  });
117
117
 
118
118
  it("should pass a feature list to the timeline", function() {
119
- spyOn(Pusher, "getClientFeatures").andReturn(["foo", "bar"]);
119
+ spyOn(Pusher, "getClientFeatures").and.returnValue(["foo", "bar"]);
120
120
  var pusher = new Pusher("foo");
121
121
  expect(pusher.timeline.options.features).toEqual(["foo", "bar"]);
122
122
  });
@@ -154,7 +154,7 @@ describe("Pusher", function() {
154
154
 
155
155
  if (TestEnv === "web") {
156
156
  it("should be on when using https", function() {
157
- Runtime.getDocument.andReturn({
157
+ Runtime.getDocument.and.returnValue({
158
158
  location: {
159
159
  protocol: "https:"
160
160
  }
@@ -294,12 +294,22 @@ describe("Pusher", function() {
294
294
  describe("#unsubscribe", function() {
295
295
  it("should unsubscribe the channel if subscription is not pending", function() {
296
296
  var channel = pusher.subscribe("yyy");
297
+ channel.subscribed = true;
297
298
  expect(channel.unsubscribe).not.toHaveBeenCalled();
298
299
 
299
300
  pusher.unsubscribe("yyy");
300
301
  expect(channel.unsubscribe).toHaveBeenCalled();
301
302
  });
302
303
 
304
+ it("should not unsubscribe the channel if the channel is not subscribed", function() {
305
+ var channel = pusher.subscribe("yyy");
306
+ channel.subscribed = false;
307
+ expect(channel.unsubscribe).not.toHaveBeenCalled();
308
+
309
+ pusher.unsubscribe("yyy");
310
+ expect(channel.unsubscribe).not.toHaveBeenCalled();
311
+ });
312
+
303
313
  it("should remove the channel from .channels if subscription is not pending", function () {
304
314
  var channel = pusher.subscribe("yyy");
305
315
  expect(pusher.channel("yyy")).toBe(channel);
@@ -445,16 +455,20 @@ describe("Pusher", function() {
445
455
  var timelineSender;
446
456
 
447
457
  beforeEach(function() {
448
- jasmine.Clock.useMock();
458
+ jasmine.clock().install();
449
459
 
450
460
  timelineSender = Mocks.getTimelineSender();
451
- spyOn(Factory, "createTimelineSender").andReturn(timelineSender);
461
+ spyOn(Factory, "createTimelineSender").and.returnValue(timelineSender);
462
+
463
+ });
452
464
 
465
+ afterEach(function() {
466
+ jasmine.clock().uninstall();
453
467
  });
454
468
 
455
469
  it("should be sent to stats.pusher.com", function() {
456
470
  var pusher = new Pusher("foo", { enableStats: true });
457
- expect(Factory.createTimelineSender.calls.length).toEqual(1);
471
+ expect(Factory.createTimelineSender.calls.count()).toEqual(1);
458
472
  expect(Factory.createTimelineSender).toHaveBeenCalledWith(
459
473
  pusher.timeline, { host: "stats.pusher.com", path: "/timeline/v2/" + timelineTransport }
460
474
  );
@@ -474,15 +488,15 @@ describe("Pusher", function() {
474
488
  var pusher = new Pusher("foo");
475
489
  pusher.connect();
476
490
  pusher.connection.options.timeline.info({});
477
- jasmine.Clock.tick(1000000);
478
- expect(timelineSender.send.calls.length).toEqual(0);
491
+ jasmine.clock().tick(1000000);
492
+ expect(timelineSender.send.calls.count()).toEqual(0);
479
493
  });
480
494
 
481
495
  it("should be sent if disableStats set to false", function() {
482
496
  var pusher = new Pusher("foo", { disableStats: false });
483
497
  pusher.connect();
484
498
  pusher.connection.options.timeline.info({});
485
- expect(Factory.createTimelineSender.calls.length).toEqual(1);
499
+ expect(Factory.createTimelineSender.calls.count()).toEqual(1);
486
500
  expect(Factory.createTimelineSender).toHaveBeenCalledWith(
487
501
  pusher.timeline, { host: "stats.pusher.com", path: "/timeline/v2/" + timelineTransport }
488
502
  );
@@ -492,7 +506,7 @@ describe("Pusher", function() {
492
506
  var pusher = new Pusher("foo", { disableStats: true, enableStats: true });
493
507
  pusher.connect();
494
508
  pusher.connection.options.timeline.info({});
495
- expect(Factory.createTimelineSender.calls.length).toEqual(1);
509
+ expect(Factory.createTimelineSender.calls.count()).toEqual(1);
496
510
  expect(Factory.createTimelineSender).toHaveBeenCalledWith(
497
511
  pusher.timeline, { host: "stats.pusher.com", path: "/timeline/v2/" + timelineTransport }
498
512
  );
@@ -501,23 +515,23 @@ describe("Pusher", function() {
501
515
  it("should not be sent before calling connect", function() {
502
516
  var pusher = new Pusher("foo", { enableStats: true });
503
517
  pusher.connection.options.timeline.info({});
504
- jasmine.Clock.tick(1000000);
505
- expect(timelineSender.send.calls.length).toEqual(0);
518
+ jasmine.clock().tick(1000000);
519
+ expect(timelineSender.send.calls.count()).toEqual(0);
506
520
  });
507
521
 
508
522
  it("should be sent every 60 seconds after calling connect", function() {
509
523
  var pusher = new Pusher("foo", { enableStats: true });
510
524
  pusher.connect();
511
- expect(Factory.createTimelineSender.calls.length).toEqual(1);
525
+ expect(Factory.createTimelineSender.calls.count()).toEqual(1);
512
526
 
513
527
  pusher.connection.options.timeline.info({});
514
528
 
515
- jasmine.Clock.tick(59999);
516
- expect(timelineSender.send.calls.length).toEqual(0);
517
- jasmine.Clock.tick(1);
518
- expect(timelineSender.send.calls.length).toEqual(1);
519
- jasmine.Clock.tick(60000);
520
- expect(timelineSender.send.calls.length).toEqual(2);
529
+ jasmine.clock().tick(59999);
530
+ expect(timelineSender.send.calls.count()).toEqual(0);
531
+ jasmine.clock().tick(1);
532
+ expect(timelineSender.send.calls.count()).toEqual(1);
533
+ jasmine.clock().tick(60000);
534
+ expect(timelineSender.send.calls.count()).toEqual(2);
521
535
  });
522
536
 
523
537
  it("should be sent after connecting", function() {
@@ -528,7 +542,7 @@ describe("Pusher", function() {
528
542
  pusher.connection.state = "connected";
529
543
  pusher.connection.emit("connected");
530
544
 
531
- expect(timelineSender.send.calls.length).toEqual(1);
545
+ expect(timelineSender.send.calls.count()).toEqual(1);
532
546
  });
533
547
 
534
548
  it("should not be sent after disconnecting", function() {
@@ -538,13 +552,13 @@ describe("Pusher", function() {
538
552
 
539
553
  pusher.connection.options.timeline.info({});
540
554
 
541
- jasmine.Clock.tick(1000000);
542
- expect(timelineSender.send.calls.length).toEqual(0);
555
+ jasmine.clock().tick(1000000);
556
+ expect(timelineSender.send.calls.count()).toEqual(0);
543
557
  });
544
558
 
545
559
  it("should be sent without TLS if connection is not using TLS", function() {
546
560
  var pusher = new Pusher("foo", { enableStats: true });
547
- pusher.connection.isUsingTLS.andReturn(false);
561
+ pusher.connection.isUsingTLS.and.returnValue(false);
548
562
 
549
563
  pusher.connect();
550
564
  pusher.connection.options.timeline.info({});
@@ -557,7 +571,7 @@ describe("Pusher", function() {
557
571
 
558
572
  it("should be sent with TLS if connection is over TLS", function() {
559
573
  var pusher = new Pusher("foo", { enableStats: true });
560
- pusher.connection.isUsingTLS.andReturn(true);
574
+ pusher.connection.isUsingTLS.and.returnValue(true);
561
575
 
562
576
  pusher.connect();
563
577
  pusher.connection.options.timeline.info({});
@@ -32,7 +32,7 @@ describe("BestConnectedEverStrategy", function() {
32
32
  expect(this.callback).toHaveBeenCalledWith(null, {
33
33
  transport: transport1
34
34
  });
35
- expect(this.callback.calls.length).toEqual(1);
35
+ expect(this.callback.calls.count()).toEqual(1);
36
36
  });
37
37
 
38
38
  it("should force min priorities on all substrategies", function() {
@@ -50,7 +50,7 @@ describe("BestConnectedEverStrategy", function() {
50
50
  expect(this.callback).toHaveBeenCalledWith(null, {
51
51
  transport: transport2
52
52
  });
53
- expect(this.callback.calls.length).toEqual(2);
53
+ expect(this.callback.calls.count()).toEqual(2);
54
54
  });
55
55
  });
56
56
 
@@ -67,12 +67,12 @@ describe("BestConnectedEverStrategy", function() {
67
67
  it("should not pass errors after one substrategy succeeded", function() {
68
68
  var transport = Mocks.getTransport();
69
69
  this.substrategies[0]._callback(null, { transport: transport });
70
- expect(this.callback.calls.length).toEqual(1);
70
+ expect(this.callback.calls.count()).toEqual(1);
71
71
 
72
72
  this.substrategies[1]._callback(true);
73
- expect(this.callback.calls.length).toEqual(1);
73
+ expect(this.callback.calls.count()).toEqual(1);
74
74
  this.substrategies[2]._callback(true);
75
- expect(this.callback.calls.length).toEqual(1);
75
+ expect(this.callback.calls.count()).toEqual(1);
76
76
  });
77
77
  });
78
78
  });
@@ -5,7 +5,11 @@ var Util = require('core/util').default;
5
5
 
6
6
  describe("CachedStrategy", function() {
7
7
  beforeEach(function() {
8
- jasmine.Clock.useMock();
8
+ jasmine.clock().install();
9
+ });
10
+
11
+ afterEach(function() {
12
+ jasmine.clock().uninstall();
9
13
  });
10
14
 
11
15
  describe("after calling isSupported", function() {
@@ -24,7 +28,7 @@ describe("CachedStrategy", function() {
24
28
 
25
29
  describe("on browsers not supporting localStorage", function() {
26
30
  beforeEach(function() {
27
- spyOn(Runtime, "getLocalStorage").andReturn(undefined);
31
+ spyOn(Runtime, "getLocalStorage").and.returnValue(undefined);
28
32
  });
29
33
 
30
34
  it("should try the substrategy immediately", function() {
@@ -41,7 +45,7 @@ describe("CachedStrategy", function() {
41
45
 
42
46
  beforeEach(function() {
43
47
  localStorage = {};
44
- spyOn(Runtime, "getLocalStorage").andReturn(localStorage);
48
+ spyOn(Runtime, "getLocalStorage").and.returnValue(localStorage);
45
49
  });
46
50
 
47
51
  function buildCachedTransportTests(useTLS) {
@@ -114,10 +118,10 @@ describe("CachedStrategy", function() {
114
118
 
115
119
  beforeEach(function() {
116
120
  startTimestamp = Util.now();
117
- spyOn(Util, "now").andReturn(startTimestamp);
121
+ spyOn(Util, "now").and.returnValue(startTimestamp);
118
122
 
119
123
  strategy.connect(0, callback);
120
- Util.now.andReturn(startTimestamp + 1000);
124
+ Util.now.and.returnValue(startTimestamp + 1000);
121
125
 
122
126
  transport = Mocks.getTransport(true);
123
127
  transport.name = "test";
@@ -208,10 +212,10 @@ describe("CachedStrategy", function() {
208
212
 
209
213
  beforeEach(function() {
210
214
  startTimestamp = Util.now();
211
- spyOn(Util, "now").andReturn(startTimestamp);
215
+ spyOn(Util, "now").and.returnValue(startTimestamp);
212
216
 
213
217
  strategy.connect(0, callback);
214
- Util.now.andReturn(startTimestamp + 2000);
218
+ Util.now.and.returnValue(startTimestamp + 2000);
215
219
 
216
220
  transport = Mocks.getTransport(true);
217
221
  transport.name = "test";
@@ -240,12 +244,12 @@ describe("CachedStrategy", function() {
240
244
  describe("after double the cached latency + 1s", function() {
241
245
  beforeEach(function() {
242
246
  startTimestamp = Util.now();
243
- spyOn(Util, "now").andReturn(startTimestamp);
247
+ spyOn(Util, "now").and.returnValue(startTimestamp);
244
248
 
245
249
  strategy.connect(0, callback);
246
250
 
247
- Util.now.andReturn(startTimestamp + 3000);
248
- jasmine.Clock.tick(3000);
251
+ Util.now.and.returnValue(startTimestamp + 3000);
252
+ jasmine.clock().tick(3000);
249
253
  });
250
254
 
251
255
  it("should abort the cached strategy", function() {
@@ -267,13 +271,13 @@ describe("CachedStrategy", function() {
267
271
 
268
272
  beforeEach(function() {
269
273
  startTimestamp = Util.now();
270
- spyOn(Util, "now").andReturn(startTimestamp);
274
+ spyOn(Util, "now").and.returnValue(startTimestamp);
271
275
 
272
276
  runner = strategy.connect(0, callback);
273
277
  runner.forceMinPriority(666);
274
- Util.now.andReturn(startTimestamp + 2000);
278
+ Util.now.and.returnValue(startTimestamp + 2000);
275
279
  transports.test._callback("error");
276
- Util.now.andReturn(startTimestamp + 2500);
280
+ Util.now.and.returnValue(startTimestamp + 2500);
277
281
  });
278
282
 
279
283
  it("should fall back to the substrategy", function() {
@@ -7,7 +7,11 @@ describe("DelayedStrategy", function() {
7
7
  this.strategy = new DelayedStrategy(this.substrategy, { delay: 0 });
8
8
  this.callback = jasmine.createSpy();
9
9
 
10
- jasmine.Clock.useMock();
10
+ jasmine.clock().install();
11
+ });
12
+
13
+ afterEach(function() {
14
+ jasmine.clock().uninstall();
11
15
  });
12
16
 
13
17
  describe("after calling isSupported", function() {
@@ -33,9 +37,9 @@ describe("DelayedStrategy", function() {
33
37
  strategy.connect(0, this.callback);
34
38
 
35
39
  expect(this.substrategy.connect).not.toHaveBeenCalled();
36
- jasmine.Clock.tick(99);
40
+ jasmine.clock().tick(99);
37
41
  expect(this.substrategy.connect).not.toHaveBeenCalled();
38
- jasmine.Clock.tick(1);
42
+ jasmine.clock().tick(1);
39
43
  expect(this.substrategy.connect).toHaveBeenCalled();
40
44
 
41
45
  var handshake = {};
@@ -46,7 +50,7 @@ describe("DelayedStrategy", function() {
46
50
 
47
51
  it("should pass an error when substrategy fails", function() {
48
52
  this.strategy.connect(0, this.callback);
49
- jasmine.Clock.tick(0);
53
+ jasmine.clock().tick(0);
50
54
  this.substrategy._callback(true);
51
55
 
52
56
  expect(this.callback).toHaveBeenCalledWith(true);
@@ -56,7 +60,7 @@ describe("DelayedStrategy", function() {
56
60
  describe("on abort", function() {
57
61
  it("should abort substrategy when connecting", function() {
58
62
  var runner = this.strategy.connect(0);
59
- jasmine.Clock.tick(0);
63
+ jasmine.clock().tick(0);
60
64
  runner.abort();
61
65
  expect(this.substrategy._abort).toHaveBeenCalled();
62
66
  });
@@ -65,7 +69,7 @@ describe("DelayedStrategy", function() {
65
69
  var run = this.strategy.connect(0);
66
70
  expect(this.substrategy.connect).not.toHaveBeenCalled();
67
71
  run.abort();
68
- jasmine.Clock.tick(10000);
72
+ jasmine.clock().tick(10000);
69
73
  expect(this.substrategy._abort).not.toHaveBeenCalled();
70
74
  expect(this.substrategy.connect).not.toHaveBeenCalled();
71
75
  });
@@ -75,14 +79,14 @@ describe("DelayedStrategy", function() {
75
79
  it("should force the priority while waiting", function() {
76
80
  var runner = this.strategy.connect(0, this.callback);
77
81
  runner.forceMinPriority(5);
78
- jasmine.Clock.tick(0);
82
+ jasmine.clock().tick(0);
79
83
  expect(this.substrategy.connect)
80
84
  .toHaveBeenCalledWith(5, jasmine.any(Function));
81
85
  });
82
86
 
83
87
  it("should force the priority while connecting", function() {
84
88
  var runner = this.strategy.connect(0, this.callback);
85
- jasmine.Clock.tick(0);
89
+ jasmine.clock().tick(0);
86
90
  runner.forceMinPriority(5);
87
91
  expect(this.substrategy._forceMinPriority).toHaveBeenCalledWith(5);
88
92
  });
@@ -7,7 +7,11 @@ describe("SequentialStrategy", function() {
7
7
  this.substrategies = Mocks.getStrategies([true, true]);
8
8
  this.strategy = new SequentialStrategy(this.substrategies, {});
9
9
 
10
- jasmine.Clock.useMock();
10
+ jasmine.clock().install();
11
+ });
12
+
13
+ afterEach(function() {
14
+ jasmine.clock().uninstall();
11
15
  });
12
16
 
13
17
  describe("after calling isSupported", function() {
@@ -51,7 +55,7 @@ describe("SequentialStrategy", function() {
51
55
  this.substrategies[1]._callback(true);
52
56
  expect(this.substrategies[1]._abort).not.toHaveBeenCalled();
53
57
  expect(this.callback).toHaveBeenCalledWith(true);
54
- expect(this.callback.calls.length).toEqual(1);
58
+ expect(this.callback.calls.count()).toEqual(1);
55
59
  });
56
60
 
57
61
  it("should support looping", function() {
@@ -60,18 +64,18 @@ describe("SequentialStrategy", function() {
60
64
  });
61
65
  var runner = strategy.connect(0, this.callback);
62
66
 
63
- expect(this.substrategies[0].connect.calls.length).toEqual(1);
64
- expect(this.substrategies[1].connect.calls.length).toEqual(0);
67
+ expect(this.substrategies[0].connect.calls.count()).toEqual(1);
68
+ expect(this.substrategies[1].connect.calls.count()).toEqual(0);
65
69
 
66
70
  this.substrategies[0]._callback(true);
67
71
 
68
- expect(this.substrategies[0].connect.calls.length).toEqual(1);
69
- expect(this.substrategies[1].connect.calls.length).toEqual(1);
72
+ expect(this.substrategies[0].connect.calls.count()).toEqual(1);
73
+ expect(this.substrategies[1].connect.calls.count()).toEqual(1);
70
74
 
71
75
  this.substrategies[1]._callback(true);
72
76
 
73
- expect(this.substrategies[0].connect.calls.length).toEqual(2);
74
- expect(this.substrategies[1].connect.calls.length).toEqual(1);
77
+ expect(this.substrategies[0].connect.calls.count()).toEqual(2);
78
+ expect(this.substrategies[1].connect.calls.count()).toEqual(1);
75
79
 
76
80
  runner.abort();
77
81
  expect(this.substrategies[0]._abort).toHaveBeenCalled();
@@ -111,7 +115,7 @@ describe("SequentialStrategy", function() {
111
115
  expect(this.substrategies[1].connect).not.toHaveBeenCalled();
112
116
 
113
117
  runner.abort();
114
- jasmine.Clock.tick(100);
118
+ jasmine.clock().tick(100);
115
119
  expect(this.substrategies[1].connect).not.toHaveBeenCalled();
116
120
  });
117
121
  });
@@ -126,9 +130,9 @@ describe("SequentialStrategy", function() {
126
130
  strategy.connect(0, this.callback);
127
131
  substrategy._callback(true);
128
132
 
129
- jasmine.Clock.tick(99);
133
+ jasmine.clock().tick(99);
130
134
  expect(this.callback).not.toHaveBeenCalled();
131
- jasmine.Clock.tick(1);
135
+ jasmine.clock().tick(1);
132
136
  expect(this.callback).toHaveBeenCalled();
133
137
  });
134
138
 
@@ -160,31 +164,31 @@ describe("SequentialStrategy", function() {
160
164
  expect(substrategies[0].connect).toHaveBeenCalled();
161
165
  expect(substrategies[1].connect).not.toHaveBeenCalled();
162
166
 
163
- jasmine.Clock.tick(99);
167
+ jasmine.clock().tick(99);
164
168
  expect(substrategies[1].connect).not.toHaveBeenCalled();
165
169
 
166
- jasmine.Clock.tick(1);
170
+ jasmine.clock().tick(1);
167
171
  expect(substrategies[1].connect).toHaveBeenCalled();
168
172
  expect(substrategies[2].connect).not.toHaveBeenCalled();
169
173
 
170
- jasmine.Clock.tick(199);
174
+ jasmine.clock().tick(199);
171
175
  expect(substrategies[2].connect).not.toHaveBeenCalled();
172
176
 
173
- jasmine.Clock.tick(1);
177
+ jasmine.clock().tick(1);
174
178
  expect(substrategies[2].connect).toHaveBeenCalled();
175
179
  expect(substrategies[3].connect).not.toHaveBeenCalled();
176
180
 
177
- jasmine.Clock.tick(399);
181
+ jasmine.clock().tick(399);
178
182
  expect(substrategies[3].connect).not.toHaveBeenCalled();
179
183
 
180
- jasmine.Clock.tick(1);
184
+ jasmine.clock().tick(1);
181
185
  expect(substrategies[3].connect).toHaveBeenCalled();
182
186
  expect(substrategies[4].connect).not.toHaveBeenCalled();
183
187
 
184
- jasmine.Clock.tick(399);
188
+ jasmine.clock().tick(399);
185
189
  expect(substrategies[4].connect).not.toHaveBeenCalled();
186
190
 
187
- jasmine.Clock.tick(1);
191
+ jasmine.clock().tick(1);
188
192
  expect(substrategies[4].connect).toHaveBeenCalled();
189
193
  });
190
194
  });