pusher-js 7.0.2 → 7.0.6
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.
- package/.github/stale.yml +2 -2
- package/.github/workflows/release.yml +112 -0
- package/.github/workflows/release_pr.yml +42 -0
- package/.github/workflows/run-tests.yml +38 -0
- package/CHANGELOG.md +26 -0
- package/Makefile +17 -12
- package/README.md +28 -0
- package/dist/node/pusher.js +85 -44
- package/dist/node/pusher.js.map +1 -0
- package/dist/react-native/pusher.js +3 -2
- package/dist/react-native/pusher.js.map +1 -0
- package/dist/web/pusher-with-encryption.js +7 -5
- package/dist/web/pusher-with-encryption.js.map +1 -0
- package/dist/web/pusher-with-encryption.min.js +3 -2
- package/dist/web/pusher-with-encryption.min.js.map +1 -0
- package/dist/web/pusher.js +7 -5
- package/dist/web/pusher.js.map +1 -0
- package/dist/web/pusher.min.js +3 -2
- package/dist/web/pusher.min.js.map +1 -0
- package/dist/worker/pusher-with-encryption.worker.js +19 -7
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -0
- package/dist/worker/pusher-with-encryption.worker.min.js +3 -2
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -0
- package/dist/worker/pusher.worker.js +19 -7
- package/dist/worker/pusher.worker.js.map +1 -0
- package/dist/worker/pusher.worker.min.js +3 -2
- package/dist/worker/pusher.worker.min.js.map +1 -0
- package/package.json +17 -15
- package/spec/config/jasmine/helpers/reporter.js +14 -0
- package/spec/config/jasmine/integration.json +13 -0
- package/spec/config/jasmine/unit.json +13 -0
- package/spec/config/{jasmine-node → jasmine}/webpack.integration.js +4 -4
- package/spec/config/{jasmine-node → jasmine}/webpack.unit.js +4 -6
- package/spec/config/karma/config.common.js +10 -4
- package/spec/config/karma/config.integration.js +4 -4
- package/spec/config/karma/config.unit.js +5 -7
- package/spec/config/karma/integration.js +3 -3
- package/spec/config/karma/unit.js +2 -2
- package/spec/javascripts/helpers/mocks.js +18 -18
- package/spec/javascripts/helpers/waitsFor.js +37 -0
- package/spec/javascripts/integration/core/cluster_config_spec.js +45 -34
- package/spec/javascripts/integration/core/falling_back_spec.js +124 -127
- package/spec/javascripts/integration/core/pusher_spec/test_builder.js +264 -284
- package/spec/javascripts/integration/core/timeout_configuration_spec.js +24 -22
- package/spec/javascripts/integration/core/transport_lists_spec.js +8 -8
- package/spec/javascripts/integration/web/dom/jsonp_spec.js +67 -69
- package/spec/javascripts/integration/web/dom/script_request_spec.js +44 -52
- package/spec/javascripts/unit/core/channels/channel_spec.js +11 -21
- package/spec/javascripts/unit/core/channels/encrypted_channel_spec.js +9 -17
- package/spec/javascripts/unit/core/channels/presence_channel_spec.js +8 -19
- package/spec/javascripts/unit/core/channels/private_channel_spec.js +9 -19
- package/spec/javascripts/unit/core/config_spec.js +2 -2
- package/spec/javascripts/unit/core/connection/connection_manager_spec.js +69 -63
- package/spec/javascripts/unit/core/connection/connection_spec.js +14 -13
- package/spec/javascripts/unit/core/connection/handshake_spec.js +14 -12
- package/spec/javascripts/unit/core/connection/protocol_spec.js +9 -4
- package/spec/javascripts/unit/core/defaults_spec.js +1 -1
- package/spec/javascripts/unit/core/events_dispatcher_spec.js +20 -20
- package/spec/javascripts/unit/core/http/http_polling_socket_spec.js +4 -4
- package/spec/javascripts/unit/core/http/http_request_spec.js +20 -17
- package/spec/javascripts/unit/core/http/http_socket_spec.js +35 -32
- package/spec/javascripts/unit/core/http/http_streaming_socket_spec.js +4 -4
- package/spec/javascripts/unit/core/http/http_xhr_request_spec.js +13 -13
- package/spec/javascripts/unit/core/pusher_authorizer_spec.js +11 -11
- package/spec/javascripts/unit/core/pusher_spec.js +31 -27
- package/spec/javascripts/unit/core/strategies/best_connected_ever_strategy_spec.js +5 -5
- package/spec/javascripts/unit/core/strategies/cached_strategy_spec.js +17 -13
- package/spec/javascripts/unit/core/strategies/delayed_strategy_spec.js +12 -8
- package/spec/javascripts/unit/core/strategies/sequential_strategy_spec.js +23 -19
- package/spec/javascripts/unit/core/strategies/transport_strategy_spec.js +22 -24
- package/spec/javascripts/unit/core/timeline/timeline_spec.js +16 -9
- package/spec/javascripts/unit/core/transports/assistant_to_the_transport_manager_spec.js +36 -22
- package/spec/javascripts/unit/core/transports/hosts_and_ports_spec.js +10 -10
- package/spec/javascripts/unit/core/transports/transport_connection_spec.js +81 -86
- package/spec/javascripts/unit/core/transports/transport_manager_spec.js +1 -1
- package/spec/javascripts/unit/core/utils/periodic_timer_spec.js +17 -16
- package/spec/javascripts/unit/core/utils/timers_spec.js +32 -26
- package/spec/javascripts/unit/isomorphic/transports/hosts_and_ports_spec.js +12 -8
- package/spec/javascripts/unit/isomorphic/transports/transports_spec.js +7 -7
- package/spec/javascripts/unit/node/timeline_sender_spec.js +5 -5
- package/spec/javascripts/unit/web/dom/dependency_loader_spec.js +30 -30
- package/spec/javascripts/unit/web/dom/jsonp_request_spec.js +7 -7
- package/spec/javascripts/unit/web/http/http_xdomain_request_spec.js +22 -22
- package/spec/javascripts/unit/web/pusher_authorizer_spec.js +3 -3
- package/spec/javascripts/unit/web/timeline/timeline_sender_spec.js +12 -12
- package/spec/javascripts/unit/web/transports/hosts_and_ports_spec.js +15 -12
- package/spec/javascripts/unit/web/transports/transports_spec.js +24 -26
- package/spec/javascripts/unit/worker/pusher_authorizer_spec.js +2 -2
- package/spec/javascripts/unit/worker/timeline_sender_spec.js +2 -2
- package/src/core/auth/options.ts +1 -0
- package/types/src/core/auth/options.d.ts +1 -0
- package/webpack/config.node.js +2 -2
- package/webpack/config.react-native.js +2 -2
- package/webpack/config.shared.js +9 -1
- package/webpack/config.web.js +2 -2
- package/webpack/config.worker.js +5 -3
- package/worker/index.d.ts +15 -0
- package/worker/index.js +1 -0
- package/worker/with-encryption/index.d.ts +15 -0
- package/worker/with-encryption/index.js +1 -0
- package/.travis.build +0 -22
- package/.travis.yml +0 -7
- package/spec/config/jasmine-node/config.js +0 -10
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pusher-js",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers",
|
|
5
5
|
"main": "dist/node/pusher.js",
|
|
6
6
|
"browser": "dist/web/pusher.js",
|
|
7
|
+
"react-native": "dist/react-native/pusher.js",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
10
|
"format": "prettier --config .prettierrc --write 'src/**/*.ts' 'webpack/**/*.js'",
|
|
@@ -30,34 +31,35 @@
|
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/pusher/pusher-js",
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@react-native-community/netinfo": "^
|
|
34
|
+
"@react-native-community/netinfo": "^5.9.7",
|
|
34
35
|
"@stablelib/base64": "^1.0.0",
|
|
35
36
|
"@stablelib/utf8": "^1.0.0",
|
|
36
37
|
"buffer": "^5.6.0",
|
|
37
|
-
"faye-websocket": "^0.
|
|
38
|
+
"faye-websocket": "^0.11.3",
|
|
38
39
|
"fetch-mock": "git+https://git@github.com/jpatel531/fetch-mock.git",
|
|
39
|
-
"isomorphic-fetch": "^
|
|
40
|
-
"jasmine
|
|
41
|
-
"jasmine-spec-reporter": "^
|
|
42
|
-
"karma": "^
|
|
43
|
-
"karma-browserstack-launcher": "^1.
|
|
44
|
-
"karma-chrome-launcher": "^
|
|
45
|
-
"karma-firefox-launcher": "^1.1
|
|
46
|
-
"karma-jasmine": "
|
|
40
|
+
"isomorphic-fetch": "^3.0.0",
|
|
41
|
+
"jasmine": "^3.8.0",
|
|
42
|
+
"jasmine-spec-reporter": "^7.0.0",
|
|
43
|
+
"karma": "^6.3.4",
|
|
44
|
+
"karma-browserstack-launcher": "^1.6.0",
|
|
45
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
46
|
+
"karma-firefox-launcher": "^2.1.1",
|
|
47
|
+
"karma-jasmine": "^4.0.1",
|
|
47
48
|
"karma-jasmine-web-worker": "^0.1.2",
|
|
48
49
|
"karma-opera-launcher": "^1.0.0",
|
|
49
50
|
"karma-safari-launcher": "^1.0.0",
|
|
50
51
|
"karma-spec-reporter": "0.0.32",
|
|
51
52
|
"karma-verbose-reporter": "0.0.6",
|
|
52
53
|
"karma-webpack": "^4.0.2",
|
|
53
|
-
"object-assign-deep": "0.0.4",
|
|
54
54
|
"prettier": "^1.19.1",
|
|
55
|
+
"source-map-loader": "^1.1.3",
|
|
55
56
|
"ts-loader": "^6.0.4",
|
|
56
57
|
"typescript": "^3.4.5",
|
|
57
58
|
"uglify-js": "^2.6.2",
|
|
58
|
-
"webpack": "^4.
|
|
59
|
-
"webpack-cli": "^3.3.
|
|
60
|
-
"webpack-dev-server": "^3.11.
|
|
59
|
+
"webpack": "^4.46.0",
|
|
60
|
+
"webpack-cli": "^3.3.12",
|
|
61
|
+
"webpack-dev-server": "^3.11.2",
|
|
62
|
+
"webpack-merge": "^5.8.0",
|
|
61
63
|
"xmlhttprequest": "^1.8.0"
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
|
2
|
+
|
|
3
|
+
jasmine.getEnv().clearReporters();
|
|
4
|
+
|
|
5
|
+
jasmine.getEnv().addReporter(
|
|
6
|
+
new SpecReporter({
|
|
7
|
+
spec: {
|
|
8
|
+
displayPending: true
|
|
9
|
+
},
|
|
10
|
+
summary: {
|
|
11
|
+
displayDuration: false
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_dir": "./tmp/node_integration",
|
|
3
|
+
"spec_files": [
|
|
4
|
+
"**/*spec.js"
|
|
5
|
+
],
|
|
6
|
+
"helpers": [
|
|
7
|
+
"../../spec/config/jasmine/helpers/**/*.js"
|
|
8
|
+
],
|
|
9
|
+
"failSpecWithNoExpectations": false,
|
|
10
|
+
"stopSpecOnExpectationFailure": false,
|
|
11
|
+
"stopOnSpecFailure": false,
|
|
12
|
+
"random": false
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_dir": "./tmp/node_unit",
|
|
3
|
+
"spec_files": [
|
|
4
|
+
"**/*spec.js"
|
|
5
|
+
],
|
|
6
|
+
"helpers": [
|
|
7
|
+
"../../spec/config/jasmine/helpers/**/*.js"
|
|
8
|
+
],
|
|
9
|
+
"failSpecWithNoExpectations": false,
|
|
10
|
+
"stopSpecOnExpectationFailure": false,
|
|
11
|
+
"stopOnSpecFailure": false,
|
|
12
|
+
"random": false
|
|
13
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const baseConfig = require('../../../webpack/config.node');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = merge({}, baseConfig, {
|
|
6
6
|
entry: {
|
|
7
7
|
pusher: path.join(
|
|
8
8
|
__dirname,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var path = require("path");
|
|
5
|
-
var dummyDependencies = {};
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const baseConfig = require('../../../webpack/config.node');
|
|
6
4
|
|
|
7
|
-
module.exports =
|
|
5
|
+
module.exports = merge({}, baseConfig, {
|
|
8
6
|
entry: {
|
|
9
7
|
pusher: path.join(
|
|
10
8
|
__dirname,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const webpackConfig = require('../../../webpack/config.shared');
|
|
3
3
|
|
|
4
4
|
var browserList;
|
|
5
5
|
if (process.env.MINIMAL_INTEGRATION_TESTS) {
|
|
@@ -14,7 +14,7 @@ module.exports = {
|
|
|
14
14
|
|
|
15
15
|
reporters: ['verbose'],
|
|
16
16
|
|
|
17
|
-
webpack:
|
|
17
|
+
webpack: merge({}, webpackConfig, {
|
|
18
18
|
mode: 'development',
|
|
19
19
|
resolve: {
|
|
20
20
|
modules: [
|
|
@@ -40,6 +40,12 @@ module.exports = {
|
|
|
40
40
|
singleRun: true,
|
|
41
41
|
client: {
|
|
42
42
|
captureConsole: false,
|
|
43
|
+
jasmine: {
|
|
44
|
+
// This new behaviour in jasmine is enabled by default but, some of our
|
|
45
|
+
// old tests rely on sequential execution.
|
|
46
|
+
// @todo Enable random order execution (i.e. remove this flag) and fix tests that are broken
|
|
47
|
+
random: false
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
|
-
}
|
|
50
|
+
};
|
|
45
51
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const commonConfig = require('./config.common');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = merge({}, commonConfig, {
|
|
6
6
|
files: [
|
|
7
7
|
'**/spec/javascripts/integration/index.web.js'
|
|
8
8
|
],
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var commonConfig = require('./config.common');
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const commonConfig = require('./config.common');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
],
|
|
4
|
+
|
|
5
|
+
module.exports = merge(commonConfig, {
|
|
6
|
+
files: ['**/spec/javascripts/unit/index.web.js'],
|
|
9
7
|
preprocessors: {
|
|
10
8
|
'**/spec/javascripts/unit/index.web.js': ['webpack']
|
|
11
9
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
2
|
var config = require('./config.integration');
|
|
3
3
|
|
|
4
4
|
if (process.env.CI) {
|
|
5
5
|
var ci = require('./config.ci');
|
|
6
|
-
config =
|
|
6
|
+
config = merge(config, ci);
|
|
7
7
|
config.browsers = ci.browsers;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ if (process.env.WORKER === 'true') {
|
|
|
12
12
|
config.webpack.resolve.alias = {
|
|
13
13
|
pusher_integration: 'core/pusher',
|
|
14
14
|
integration: 'node/integration'
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
if (process.env.CI) config.browsers = ['bs_chrome_74'];
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
2
|
var config = require('./config.unit');
|
|
3
3
|
|
|
4
4
|
if (process.env.CI) {
|
|
5
5
|
var ci = require('./config.ci');
|
|
6
|
-
config =
|
|
6
|
+
config = merge(config, ci);
|
|
7
7
|
config.browsers = ci.browsers;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -94,17 +94,17 @@ var Mocks = {
|
|
|
94
94
|
var transport = new EventsDispatcher();
|
|
95
95
|
|
|
96
96
|
transport.handlesActivityChecks = jasmine.createSpy("handlesActivityChecks")
|
|
97
|
-
.
|
|
97
|
+
.and.returnValue(false);
|
|
98
98
|
transport.supportsPing = jasmine.createSpy("supportsPing")
|
|
99
|
-
.
|
|
99
|
+
.and.returnValue(false);
|
|
100
100
|
transport.initialize = jasmine.createSpy("initialize")
|
|
101
|
-
.
|
|
101
|
+
.and.callFake(function() {
|
|
102
102
|
transport.state = "initializing";
|
|
103
103
|
transport.emit("initializing");
|
|
104
104
|
});
|
|
105
105
|
transport.connect = jasmine.createSpy("connect");
|
|
106
106
|
transport.send = jasmine.createSpy("send")
|
|
107
|
-
.
|
|
107
|
+
.and.returnValue(true);
|
|
108
108
|
transport.ping = jasmine.createSpy("ping");
|
|
109
109
|
transport.close = jasmine.createSpy("close");
|
|
110
110
|
transport.state = undefined;
|
|
@@ -114,7 +114,7 @@ var Mocks = {
|
|
|
114
114
|
|
|
115
115
|
getTransportManager: function(alive) {
|
|
116
116
|
return {
|
|
117
|
-
isAlive: jasmine.createSpy("isAlive").
|
|
117
|
+
isAlive: jasmine.createSpy("isAlive").and.returnValue(alive !== false),
|
|
118
118
|
reportDeath: jasmine.createSpy("reportDeath")
|
|
119
119
|
};
|
|
120
120
|
},
|
|
@@ -122,9 +122,9 @@ var Mocks = {
|
|
|
122
122
|
getAssistantToTheTransportManager: function(transport) {
|
|
123
123
|
return {
|
|
124
124
|
createConnection: jasmine.createSpy("createConnection")
|
|
125
|
-
.
|
|
125
|
+
.and.returnValue(transport || this.getTransport()),
|
|
126
126
|
isSupported: jasmine.createSpy("isSupported")
|
|
127
|
-
.
|
|
127
|
+
.and.returnValue(true)
|
|
128
128
|
};
|
|
129
129
|
},
|
|
130
130
|
|
|
@@ -132,9 +132,9 @@ var Mocks = {
|
|
|
132
132
|
var klass = {};
|
|
133
133
|
|
|
134
134
|
klass.isSupported = jasmine.createSpy("isSupported")
|
|
135
|
-
.
|
|
135
|
+
.and.returnValue(supported);
|
|
136
136
|
klass.createConnection = jasmine.createSpy("createConnection")
|
|
137
|
-
.
|
|
137
|
+
.and.returnValue(transport || this.getTransport());
|
|
138
138
|
|
|
139
139
|
return klass;
|
|
140
140
|
},
|
|
@@ -156,9 +156,9 @@ var Mocks = {
|
|
|
156
156
|
strategy._callback = null;
|
|
157
157
|
|
|
158
158
|
strategy.isSupported = jasmine.createSpy("isSupported")
|
|
159
|
-
.
|
|
159
|
+
.and.returnValue(isSupported);
|
|
160
160
|
strategy.connect = jasmine.createSpy("connect")
|
|
161
|
-
.
|
|
161
|
+
.and.callFake(function(minPriority, callback) {
|
|
162
162
|
strategy._callback = callback;
|
|
163
163
|
return {
|
|
164
164
|
abort: strategy._abort,
|
|
@@ -183,15 +183,15 @@ var Mocks = {
|
|
|
183
183
|
connection.initialize = jasmine.createSpy("initialize");
|
|
184
184
|
connection.connect = jasmine.createSpy("connect");
|
|
185
185
|
connection.handlesActivityChecks = jasmine.createSpy("handlesActivityChecks")
|
|
186
|
-
.
|
|
186
|
+
.and.returnValue(false);
|
|
187
187
|
connection.supportsPing = jasmine.createSpy("supportsPing")
|
|
188
|
-
.
|
|
188
|
+
.and.returnValue(false);
|
|
189
189
|
connection.send = jasmine.createSpy("send")
|
|
190
|
-
.
|
|
190
|
+
.and.returnValue(true);
|
|
191
191
|
connection.ping = jasmine.createSpy("ping")
|
|
192
|
-
.
|
|
192
|
+
.and.returnValue(true);
|
|
193
193
|
connection.send_event = jasmine.createSpy("send_event")
|
|
194
|
-
.
|
|
194
|
+
.and.returnValue(true);
|
|
195
195
|
connection.close = jasmine.createSpy("close");
|
|
196
196
|
|
|
197
197
|
return connection;
|
|
@@ -203,7 +203,7 @@ var Mocks = {
|
|
|
203
203
|
manager.connect = jasmine.createSpy("connect");
|
|
204
204
|
manager.disconnect = jasmine.createSpy("disconnect");
|
|
205
205
|
manager.send_event = jasmine.createSpy("send_event");
|
|
206
|
-
manager.isUsingTLS = jasmine.createSpy("isUsingTLS").
|
|
206
|
+
manager.isUsingTLS = jasmine.createSpy("isUsingTLS").and.returnValue(false);
|
|
207
207
|
return manager;
|
|
208
208
|
},
|
|
209
209
|
|
|
@@ -231,7 +231,7 @@ var Mocks = {
|
|
|
231
231
|
getAuthorizer: function() {
|
|
232
232
|
var authorizer = {};
|
|
233
233
|
authorizer._callback = null;
|
|
234
|
-
authorizer.authorize = jasmine.createSpy("authorize").
|
|
234
|
+
authorizer.authorize = jasmine.createSpy("authorize").and.callFake(function(_, callback) {
|
|
235
235
|
authorizer._callback = callback;
|
|
236
236
|
});
|
|
237
237
|
return authorizer;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let interval = 50;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* waitsFor backports the jasmine@1.x.x waitsFor feature to keep old tests working
|
|
5
|
+
*
|
|
6
|
+
* @deprecated You shouldn't use this for writing new tests
|
|
7
|
+
*
|
|
8
|
+
* @param {Function} condition
|
|
9
|
+
* @param {string} reason
|
|
10
|
+
* @param {number} timeout
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
module.exports = async (condition, reason, timeout) => {
|
|
14
|
+
if (typeof condition !== 'function') {
|
|
15
|
+
throw new Error('Condition is not a function');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (typeof reason !== 'string') {
|
|
19
|
+
throw new Error('Reason is not a string');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof timeout !== 'number') {
|
|
23
|
+
throw new Error('Timeout is not a number');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
while (timeout >= 0) {
|
|
27
|
+
if (condition()) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await new Promise(r => setTimeout(r, interval));
|
|
32
|
+
|
|
33
|
+
timeout -= interval;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error(`waitsFor on "${reason}" timed out`);
|
|
37
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const TestEnv = require('testenv');
|
|
2
|
+
const Pusher = require('pusher_integration');
|
|
3
|
+
const DependenciesModule = require('dom/dependencies');
|
|
4
|
+
const DependenciesReceiversModule = require('dom/dependency_loader');
|
|
5
|
+
const waitsFor = require('../../helpers/waitsFor');
|
|
5
6
|
|
|
6
7
|
if (TestEnv === "web") {
|
|
7
8
|
window.Pusher = Pusher;
|
|
@@ -10,12 +11,11 @@ if (TestEnv === "web") {
|
|
|
10
11
|
var DependencyLoader = DependenciesReceiversModule.default;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var TRANSPORTS = Runtime.Transports;
|
|
14
|
+
const Integration = require("integration");
|
|
15
|
+
const Collections = require("core/utils/collections");
|
|
16
|
+
const Runtime = require('runtime').default;
|
|
17
|
+
const Defaults = require('core/defaults').default;
|
|
18
|
+
const TRANSPORTS = Runtime.Transports;
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
module.exports = function(testConfigs) {
|
|
@@ -38,16 +38,25 @@ module.exports = function(testConfigs) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
describe("with " + options.transport + ", forceTLS=" + options.forceTLS, function() {
|
|
41
|
+
var jasmineDefaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
|
42
|
+
|
|
43
|
+
beforeAll(() => {
|
|
44
|
+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 21000;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterAll(() => {
|
|
48
|
+
jasmine.DEFAULT_TIMEOUT_INTERVAL = jasmineDefaultTimeout;
|
|
49
|
+
});
|
|
50
|
+
|
|
41
51
|
beforeEach(function() {
|
|
42
52
|
Collections.objectApply(TRANSPORTS, function(transport, name) {
|
|
43
|
-
spyOn(transport, "isSupported").
|
|
53
|
+
spyOn(transport, "isSupported").and.returnValue(false);
|
|
44
54
|
});
|
|
45
|
-
TRANSPORTS[options.transport].isSupported.
|
|
46
|
-
spyOn(Runtime, "getLocalStorage").
|
|
55
|
+
TRANSPORTS[options.transport].isSupported.and.returnValue(true);
|
|
56
|
+
spyOn(Runtime, "getLocalStorage").and.returnValue({});
|
|
47
57
|
});
|
|
48
58
|
|
|
49
|
-
it("should open a connection to the 'eu' cluster", function() {
|
|
50
|
-
|
|
59
|
+
it("should open a connection to the 'eu' cluster", async function() {
|
|
51
60
|
var authTransport = (TestEnv === "web") ? 'jsonp' : 'ajax';
|
|
52
61
|
|
|
53
62
|
pusher = new Pusher("4d31fbea7080e3b4bf6d", {
|
|
@@ -56,12 +65,15 @@ module.exports = function(testConfigs) {
|
|
|
56
65
|
cluster: "eu",
|
|
57
66
|
forceTLS: options.forceTLS,
|
|
58
67
|
});
|
|
59
|
-
|
|
68
|
+
|
|
69
|
+
await waitsFor(function() {
|
|
60
70
|
return pusher.connection.state === "connected";
|
|
61
71
|
}, "connection to be established", 20000);
|
|
72
|
+
|
|
73
|
+
expect(pusher.connection.state).toEqual('connected');
|
|
62
74
|
});
|
|
63
75
|
|
|
64
|
-
it("should subscribe and receive a message sent via REST API", function() {
|
|
76
|
+
it("should subscribe and receive a message sent via REST API", async function() {
|
|
65
77
|
var channelName = Integration.getRandomName("private-integration");
|
|
66
78
|
|
|
67
79
|
var onSubscribed = jasmine.createSpy("onSubscribed");
|
|
@@ -71,27 +83,26 @@ module.exports = function(testConfigs) {
|
|
|
71
83
|
var data = { x: 1, y: "z" };
|
|
72
84
|
var received = null;
|
|
73
85
|
|
|
74
|
-
waitsFor(function() {
|
|
75
|
-
return onSubscribed.calls.
|
|
86
|
+
await waitsFor(function() {
|
|
87
|
+
return onSubscribed.calls.count();
|
|
76
88
|
}, "subscription to succeed", 10000);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
89
|
+
|
|
90
|
+
channel.bind(eventName, function(message) {
|
|
91
|
+
received = message;
|
|
92
|
+
});
|
|
93
|
+
Integration.sendAPIMessage({
|
|
94
|
+
url: Integration.API_EU_URL + "/v2/send",
|
|
95
|
+
channel: channelName,
|
|
96
|
+
event: eventName,
|
|
97
|
+
data: data
|
|
87
98
|
});
|
|
88
|
-
|
|
99
|
+
|
|
100
|
+
await waitsFor(function() {
|
|
89
101
|
return received !== null;
|
|
90
102
|
}, "message to get delivered", 10000);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
103
|
+
|
|
104
|
+
expect(received).toEqual(data);
|
|
105
|
+
pusher.unsubscribe(channelName);
|
|
95
106
|
});
|
|
96
107
|
|
|
97
108
|
it("should disconnect the connection", function() {
|