@webex/calling 3.12.0-next.4 → 3.12.0-next.40
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/dist/CallingClient/CallingClient.js +463 -205
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +170 -77
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +589 -445
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +695 -445
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +53 -30
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +35 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +2 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +25 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +4 -1
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +16 -1
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +712 -406
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +202 -21
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +46 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +211 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +354 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +881 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +13 -11
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Events/types.js +1 -11
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +63 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +357 -1
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +19 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/common/Utils.js +138 -44
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/testUtil.js +8 -4
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +2 -0
- package/dist/common/types.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +143 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +492 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +841 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1845 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +55 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +604 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +727 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallingClient/CallingClient.js +141 -10
- package/dist/module/CallingClient/calling/call.js +177 -61
- package/dist/module/CallingClient/calling/callManager.js +27 -7
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +21 -0
- package/dist/module/CallingClient/line/index.js +2 -2
- package/dist/module/CallingClient/registration/register.js +234 -62
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +30 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +165 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
- package/dist/module/Contacts/ContactsClient.js +1 -1
- package/dist/module/Events/types.js +0 -10
- package/dist/module/Metrics/index.js +48 -1
- package/dist/module/Metrics/types.js +18 -0
- package/dist/module/common/Utils.js +52 -12
- package/dist/module/common/testUtil.js +5 -1
- package/dist/module/common/types.js +2 -0
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +58 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +589 -0
- package/dist/module/mobius-socket/socket/constants.js +26 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +368 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +7 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +12 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +3 -2
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +34 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +21 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +7 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +4 -2
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +30 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +24 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +29 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Events/types.d.ts +4 -11
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +19 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +24 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +9 -2
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +4 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +3 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +20 -5
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -32,9 +32,17 @@ var _constants = require("../constants");
|
|
|
32
32
|
var _types4 = require("../line/types");
|
|
33
33
|
var _LineError = require("../../Errors/catalog/LineError");
|
|
34
34
|
var _types5 = require("../../Metrics/types");
|
|
35
|
+
var _request = require("../utils/request");
|
|
35
36
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
36
37
|
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
38
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @typescript-eslint/no-shadow */
|
|
39
|
+
jest.mock('../../mobius-socket', function () {
|
|
40
|
+
return {
|
|
41
|
+
getMobiusSocketInstance: jest.fn().mockReturnValue({
|
|
42
|
+
sendWssRequest: jest.fn()
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
38
46
|
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
39
47
|
var MockServiceData = {
|
|
40
48
|
indicator: _types.ServiceIndicator.CALLING,
|
|
@@ -137,6 +145,11 @@ describe('Registration Tests', function () {
|
|
|
137
145
|
metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
|
|
138
146
|
};
|
|
139
147
|
beforeEach(function () {
|
|
148
|
+
_request.APIRequest.resetInstance();
|
|
149
|
+
_request.APIRequest.getInstance({
|
|
150
|
+
webex: webex,
|
|
151
|
+
isMobiusSocketEnabled: false
|
|
152
|
+
});
|
|
140
153
|
setupRegistration(MockServiceData);
|
|
141
154
|
});
|
|
142
155
|
afterEach(function () {
|
|
@@ -170,7 +183,7 @@ describe('Registration Tests', function () {
|
|
|
170
183
|
// Check that log.log was called for successful registration
|
|
171
184
|
expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId, " responseTrackingId: webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15"), expect.objectContaining({
|
|
172
185
|
file: _constants.REGISTRATION_FILE,
|
|
173
|
-
method:
|
|
186
|
+
method: _constants.REGISTER_UTIL
|
|
174
187
|
}));
|
|
175
188
|
expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'PRIMARY', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
|
|
176
189
|
case 2:
|
|
@@ -218,6 +231,9 @@ describe('Registration Tests', function () {
|
|
|
218
231
|
devices: [_registerFixtures.mockPostResponse.device]
|
|
219
232
|
},
|
|
220
233
|
statusCode: 403
|
|
234
|
+
}).mockResolvedValueOnce({
|
|
235
|
+
statusCode: 200,
|
|
236
|
+
body: _registerFixtures.mockDeleteResponse
|
|
221
237
|
}).mockResolvedValueOnce({
|
|
222
238
|
statusCode: 200,
|
|
223
239
|
body: _registerFixtures.mockPostResponse,
|
|
@@ -225,25 +241,18 @@ describe('Registration Tests', function () {
|
|
|
225
241
|
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
226
242
|
}
|
|
227
243
|
});
|
|
228
|
-
global.fetch = jest.fn(function () {
|
|
229
|
-
return _promise.default.resolve({
|
|
230
|
-
json: function json() {
|
|
231
|
-
return _registerFixtures.mockDeleteResponse;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
244
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
236
245
|
_context3.next = 1;
|
|
237
246
|
return reg.triggerRegistration();
|
|
238
247
|
case 1:
|
|
239
|
-
expect(webex.request).toBeCalledTimes(
|
|
248
|
+
expect(webex.request).toBeCalledTimes(3);
|
|
240
249
|
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
241
250
|
method: 'POST'
|
|
242
251
|
}));
|
|
243
|
-
expect(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
252
|
+
expect(webex.request).toBeCalledWith(expect.objectContaining({
|
|
253
|
+
uri: _registerFixtures.mockPostResponse.device.uri,
|
|
254
|
+
method: 'DELETE'
|
|
255
|
+
}));
|
|
247
256
|
expect(warnSpy).toBeCalledWith('User device limit exceeded', expect.anything());
|
|
248
257
|
expect(infoSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
|
|
249
258
|
expect(infoSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
|
|
@@ -1277,11 +1286,8 @@ describe('Registration Tests', function () {
|
|
|
1277
1286
|
expect(reg.webWorker).toBeDefined();
|
|
1278
1287
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1279
1288
|
type: 'START_KEEPALIVE',
|
|
1280
|
-
accessToken: expect.any(String),
|
|
1281
|
-
deviceUrl: expect.any(String),
|
|
1282
1289
|
interval: expect.any(Number),
|
|
1283
|
-
retryCountThreshold: expect.any(Number)
|
|
1284
|
-
url: expect.any(String)
|
|
1290
|
+
retryCountThreshold: expect.any(Number)
|
|
1285
1291
|
}));
|
|
1286
1292
|
reg.webWorker.onmessage({
|
|
1287
1293
|
data: {
|
|
@@ -1746,11 +1752,8 @@ describe('Registration Tests', function () {
|
|
|
1746
1752
|
expect(reg.webWorker).toBeDefined();
|
|
1747
1753
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1748
1754
|
type: 'START_KEEPALIVE',
|
|
1749
|
-
accessToken: expect.any(String),
|
|
1750
|
-
deviceUrl: expect.any(String),
|
|
1751
1755
|
interval: expect.any(Number),
|
|
1752
|
-
retryCountThreshold: expect.any(Number)
|
|
1753
|
-
url: expect.any(String)
|
|
1756
|
+
retryCountThreshold: expect.any(Number)
|
|
1754
1757
|
}));
|
|
1755
1758
|
case 4:
|
|
1756
1759
|
case "end":
|
|
@@ -1881,5 +1884,183 @@ describe('Registration Tests', function () {
|
|
|
1881
1884
|
}, _callee39);
|
|
1882
1885
|
})));
|
|
1883
1886
|
});
|
|
1887
|
+
describe('handleRegistrationDownEvent tests', function () {
|
|
1888
|
+
var registrationDownEvent = {
|
|
1889
|
+
type: 'async_event',
|
|
1890
|
+
eventId: 'evt-1',
|
|
1891
|
+
trackingId: 'tid-1',
|
|
1892
|
+
data: {
|
|
1893
|
+
eventType: 'registration.down',
|
|
1894
|
+
deviceInfo: {
|
|
1895
|
+
userId: 'u1',
|
|
1896
|
+
device: {
|
|
1897
|
+
deviceId: 'd1',
|
|
1898
|
+
uri: 'https://mobius/device/d1',
|
|
1899
|
+
status: 'ACTIVE'
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
|
|
1905
|
+
return _regenerator.default.wrap(function (_context40) {
|
|
1906
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
1907
|
+
case 0:
|
|
1908
|
+
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
1909
|
+
_context40.next = 1;
|
|
1910
|
+
return reg.triggerRegistration();
|
|
1911
|
+
case 1:
|
|
1912
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1913
|
+
case 2:
|
|
1914
|
+
case "end":
|
|
1915
|
+
return _context40.stop();
|
|
1916
|
+
}
|
|
1917
|
+
}, _callee40);
|
|
1918
|
+
})));
|
|
1919
|
+
afterEach(function () {
|
|
1920
|
+
var calls = (0, _values.default)(reg.callManager.getActiveCalls());
|
|
1921
|
+
calls.forEach(function (call) {
|
|
1922
|
+
call.end();
|
|
1923
|
+
});
|
|
1924
|
+
reg.callManager.callCollection = {};
|
|
1925
|
+
});
|
|
1926
|
+
it('runs cleanup immediately when no active calls are present (socket disabled)', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
|
|
1927
|
+
var clearKeepaliveSpy, setStatusSpy, disconnectSocketSpy;
|
|
1928
|
+
return _regenerator.default.wrap(function (_context41) {
|
|
1929
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
1930
|
+
case 0:
|
|
1931
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1932
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
1933
|
+
disconnectSocketSpy = jest.spyOn(_request.APIRequest.getInstance({
|
|
1934
|
+
webex: webex
|
|
1935
|
+
}), 'disconnectFromMobiusSocket');
|
|
1936
|
+
lineEmitter.mockClear();
|
|
1937
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
1938
|
+
_context41.next = 1;
|
|
1939
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
1940
|
+
case 1:
|
|
1941
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
1942
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
1943
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
1944
|
+
expect(reg.reconnectPending).toBe(false);
|
|
1945
|
+
expect(reg.scheduled429Retry).toBe(false);
|
|
1946
|
+
expect(reg.failoverImmediately).toBe(false);
|
|
1947
|
+
expect(reg.retryAfter).toBeUndefined();
|
|
1948
|
+
expect(reg.registerRetry).toBe(false);
|
|
1949
|
+
expect(disconnectSocketSpy).not.toHaveBeenCalled();
|
|
1950
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1951
|
+
case 2:
|
|
1952
|
+
case "end":
|
|
1953
|
+
return _context41.stop();
|
|
1954
|
+
}
|
|
1955
|
+
}, _callee41);
|
|
1956
|
+
})));
|
|
1957
|
+
it('ends the active call and still runs cleanup when an active call is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
|
|
1958
|
+
var clearKeepaliveSpy, setStatusSpy, activeCall, endSpy;
|
|
1959
|
+
return _regenerator.default.wrap(function (_context42) {
|
|
1960
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
1961
|
+
case 0:
|
|
1962
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1963
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
1964
|
+
activeCall = reg.callManager.createCall();
|
|
1965
|
+
endSpy = jest.spyOn(activeCall, 'end');
|
|
1966
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
1967
|
+
lineEmitter.mockClear();
|
|
1968
|
+
_context42.next = 1;
|
|
1969
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
1970
|
+
case 1:
|
|
1971
|
+
expect(endSpy).toHaveBeenCalledTimes(1);
|
|
1972
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
1973
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
1974
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
1975
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1976
|
+
case 2:
|
|
1977
|
+
case "end":
|
|
1978
|
+
return _context42.stop();
|
|
1979
|
+
}
|
|
1980
|
+
}, _callee42);
|
|
1981
|
+
})));
|
|
1982
|
+
it('runs cleanup without calling end when no active call is present on re-invocation', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
|
|
1983
|
+
var clearKeepaliveSpy, setStatusSpy;
|
|
1984
|
+
return _regenerator.default.wrap(function (_context43) {
|
|
1985
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
1986
|
+
case 0:
|
|
1987
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1988
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
1989
|
+
_context43.next = 1;
|
|
1990
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
1991
|
+
case 1:
|
|
1992
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
1993
|
+
clearKeepaliveSpy.mockClear();
|
|
1994
|
+
setStatusSpy.mockClear();
|
|
1995
|
+
lineEmitter.mockClear();
|
|
1996
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
1997
|
+
_context43.next = 2;
|
|
1998
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
1999
|
+
case 2:
|
|
2000
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2001
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2002
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2003
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
2004
|
+
case 3:
|
|
2005
|
+
case "end":
|
|
2006
|
+
return _context43.stop();
|
|
2007
|
+
}
|
|
2008
|
+
}, _callee43);
|
|
2009
|
+
})));
|
|
2010
|
+
it('disconnects the Mobius WebSocket when socket is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
|
|
2011
|
+
var apiRequest, disconnectSocketSpy;
|
|
2012
|
+
return _regenerator.default.wrap(function (_context44) {
|
|
2013
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
2014
|
+
case 0:
|
|
2015
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2016
|
+
webex: webex
|
|
2017
|
+
});
|
|
2018
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2019
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
|
|
2020
|
+
lineEmitter.mockClear();
|
|
2021
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2022
|
+
_context44.next = 1;
|
|
2023
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2024
|
+
case 1:
|
|
2025
|
+
expect(disconnectSocketSpy).toHaveBeenCalledWith({
|
|
2026
|
+
code: 3050,
|
|
2027
|
+
reason: 'done (permanent)'
|
|
2028
|
+
});
|
|
2029
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2030
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
2031
|
+
case 2:
|
|
2032
|
+
case "end":
|
|
2033
|
+
return _context44.stop();
|
|
2034
|
+
}
|
|
2035
|
+
}, _callee44);
|
|
2036
|
+
})));
|
|
2037
|
+
it('still emits UNREGISTERED when socket disconnect fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45() {
|
|
2038
|
+
var apiRequest, disconnectSocketSpy;
|
|
2039
|
+
return _regenerator.default.wrap(function (_context45) {
|
|
2040
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
2041
|
+
case 0:
|
|
2042
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2043
|
+
webex: webex
|
|
2044
|
+
});
|
|
2045
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2046
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
|
|
2047
|
+
lineEmitter.mockClear();
|
|
2048
|
+
_context45.next = 1;
|
|
2049
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2050
|
+
case 1:
|
|
2051
|
+
expect(disconnectSocketSpy).toHaveBeenCalled();
|
|
2052
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after registration-down'), {
|
|
2053
|
+
file: _constants.REGISTRATION_FILE,
|
|
2054
|
+
method: _constants.METHODS.HANDLE_REGISTRATION_DOWN_EVENT
|
|
2055
|
+
});
|
|
2056
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2057
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
2058
|
+
case 2:
|
|
2059
|
+
case "end":
|
|
2060
|
+
return _context45.stop();
|
|
2061
|
+
}
|
|
2062
|
+
}, _callee45);
|
|
2063
|
+
})));
|
|
2064
|
+
});
|
|
1884
2065
|
});
|
|
1885
2066
|
//# sourceMappingURL=register.test.js.map
|