@webex/calling 3.9.0-multipleLLM.2 → 3.9.0-next.10

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 (174) hide show
  1. package/dist/CallHistory/CallHistory.js +51 -46
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +146 -147
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallHistory/callHistoryFixtures.js.map +1 -1
  6. package/dist/CallHistory/constants.js.map +1 -1
  7. package/dist/CallHistory/types.js.map +1 -1
  8. package/dist/CallSettings/CallSettings.js +8 -8
  9. package/dist/CallSettings/CallSettings.js.map +1 -1
  10. package/dist/CallSettings/CallSettings.test.js +1 -1
  11. package/dist/CallSettings/CallSettings.test.js.map +1 -1
  12. package/dist/CallSettings/UcmBackendConnector.js +12 -11
  13. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  14. package/dist/CallSettings/UcmBackendConnector.test.js +9 -10
  15. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  16. package/dist/CallSettings/WxCallBackendConnector.js +66 -59
  17. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  18. package/dist/CallSettings/WxCallBackendConnector.test.js +108 -109
  19. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  20. package/dist/CallSettings/constants.js.map +1 -1
  21. package/dist/CallSettings/testFixtures.js.map +1 -1
  22. package/dist/CallSettings/types.js.map +1 -1
  23. package/dist/CallingClient/CallingClient.js +452 -216
  24. package/dist/CallingClient/CallingClient.js.map +1 -1
  25. package/dist/CallingClient/CallingClient.test.js +374 -321
  26. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  27. package/dist/CallingClient/callRecordFixtures.js.map +1 -1
  28. package/dist/CallingClient/calling/CallerId/index.js +2 -2
  29. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  30. package/dist/CallingClient/calling/CallerId/index.test.js +8 -7
  31. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  32. package/dist/CallingClient/calling/CallerId/types.js.map +1 -1
  33. package/dist/CallingClient/calling/call.js +343 -320
  34. package/dist/CallingClient/calling/call.js.map +1 -1
  35. package/dist/CallingClient/calling/call.test.js +405 -406
  36. package/dist/CallingClient/calling/call.test.js.map +1 -1
  37. package/dist/CallingClient/calling/callManager.js +3 -4
  38. package/dist/CallingClient/calling/callManager.js.map +1 -1
  39. package/dist/CallingClient/calling/callManager.test.js +67 -68
  40. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  41. package/dist/CallingClient/calling/index.js.map +1 -1
  42. package/dist/CallingClient/calling/types.js.map +1 -1
  43. package/dist/CallingClient/callingClientFixtures.js.map +1 -1
  44. package/dist/CallingClient/constants.js +8 -6
  45. package/dist/CallingClient/constants.js.map +1 -1
  46. package/dist/CallingClient/line/index.js +7 -7
  47. package/dist/CallingClient/line/index.js.map +1 -1
  48. package/dist/CallingClient/line/line.test.js +6 -6
  49. package/dist/CallingClient/line/line.test.js.map +1 -1
  50. package/dist/CallingClient/line/types.js.map +1 -1
  51. package/dist/CallingClient/registration/index.js.map +1 -1
  52. package/dist/CallingClient/registration/register.js +243 -234
  53. package/dist/CallingClient/registration/register.js.map +1 -1
  54. package/dist/CallingClient/registration/register.test.js +172 -173
  55. package/dist/CallingClient/registration/register.test.js.map +1 -1
  56. package/dist/CallingClient/registration/registerFixtures.js.map +1 -1
  57. package/dist/CallingClient/registration/types.js.map +1 -1
  58. package/dist/CallingClient/registration/webWorker.js +5 -4
  59. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  60. package/dist/CallingClient/registration/webWorker.test.js +14 -14
  61. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  62. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
  63. package/dist/CallingClient/types.js.map +1 -1
  64. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +2 -6
  65. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -1
  66. package/dist/Contacts/ContactsClient.js +244 -238
  67. package/dist/Contacts/ContactsClient.js.map +1 -1
  68. package/dist/Contacts/ContactsClient.test.js +89 -90
  69. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  70. package/dist/Contacts/constants.js +2 -2
  71. package/dist/Contacts/constants.js.map +1 -1
  72. package/dist/Contacts/contactFixtures.js.map +1 -1
  73. package/dist/Contacts/types.js.map +1 -1
  74. package/dist/Errors/catalog/CallError.js +2 -2
  75. package/dist/Errors/catalog/CallError.js.map +1 -1
  76. package/dist/Errors/catalog/CallingDeviceError.js +2 -2
  77. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
  78. package/dist/Errors/catalog/ExtendedError.js +3 -3
  79. package/dist/Errors/catalog/ExtendedError.js.map +1 -1
  80. package/dist/Errors/catalog/LineError.js +2 -2
  81. package/dist/Errors/catalog/LineError.js.map +1 -1
  82. package/dist/Errors/index.js.map +1 -1
  83. package/dist/Errors/types.js.map +1 -1
  84. package/dist/Events/impl/index.js +2 -2
  85. package/dist/Events/impl/index.js.map +1 -1
  86. package/dist/Events/types.js.map +1 -1
  87. package/dist/Logger/index.js.map +1 -1
  88. package/dist/Logger/index.test.js.map +1 -1
  89. package/dist/Logger/types.js.map +1 -1
  90. package/dist/Metrics/index.js +136 -50
  91. package/dist/Metrics/index.js.map +1 -1
  92. package/dist/Metrics/index.test.js.map +1 -1
  93. package/dist/Metrics/types.js +15 -1
  94. package/dist/Metrics/types.js.map +1 -1
  95. package/dist/SDKConnector/index.js +0 -1
  96. package/dist/SDKConnector/index.js.map +1 -1
  97. package/dist/SDKConnector/index.test.js.map +1 -1
  98. package/dist/SDKConnector/types.js.map +1 -1
  99. package/dist/SDKConnector/utils.js.map +1 -1
  100. package/dist/SDKConnector/utils.test.js.map +1 -1
  101. package/dist/Voicemail/BroadworksBackendConnector.js +42 -39
  102. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  103. package/dist/Voicemail/BroadworksBackendConnector.test.js +119 -120
  104. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  105. package/dist/Voicemail/UcmBackendConnector.js +54 -47
  106. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  107. package/dist/Voicemail/UcmBackendConnector.test.js +73 -74
  108. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  109. package/dist/Voicemail/Voicemail.js +12 -11
  110. package/dist/Voicemail/Voicemail.js.map +1 -1
  111. package/dist/Voicemail/Voicemail.test.js +2 -2
  112. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  113. package/dist/Voicemail/WxCallBackendConnector.js +78 -70
  114. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  115. package/dist/Voicemail/WxCallBackendConnector.test.js +184 -185
  116. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  117. package/dist/Voicemail/constants.js.map +1 -1
  118. package/dist/Voicemail/types.js.map +1 -1
  119. package/dist/Voicemail/voicemailFixture.js.map +1 -1
  120. package/dist/api.js.map +1 -1
  121. package/dist/common/Utils.js +80 -63
  122. package/dist/common/Utils.js.map +1 -1
  123. package/dist/common/Utils.test.js +95 -104
  124. package/dist/common/Utils.test.js.map +1 -1
  125. package/dist/common/constants.js.map +1 -1
  126. package/dist/common/index.js.map +1 -1
  127. package/dist/common/testUtil.js +1 -1
  128. package/dist/common/testUtil.js.map +1 -1
  129. package/dist/common/types.js.map +1 -1
  130. package/dist/index.js +5 -5
  131. package/dist/index.js.map +1 -1
  132. package/dist/module/CallHistory/CallHistory.js +4 -0
  133. package/dist/module/CallSettings/UcmBackendConnector.js +1 -0
  134. package/dist/module/CallSettings/WxCallBackendConnector.js +7 -0
  135. package/dist/module/CallingClient/CallingClient.js +171 -43
  136. package/dist/module/CallingClient/calling/call.js +66 -43
  137. package/dist/module/CallingClient/constants.js +7 -4
  138. package/dist/module/CallingClient/registration/register.js +10 -7
  139. package/dist/module/CallingClient/registration/webWorker.js +2 -1
  140. package/dist/module/CallingClient/windowsChromiumIceWarmupUtils.js +1 -4
  141. package/dist/module/Contacts/ContactsClient.js +23 -17
  142. package/dist/module/Contacts/constants.js +1 -1
  143. package/dist/module/Metrics/index.js +63 -1
  144. package/dist/module/Metrics/types.js +14 -0
  145. package/dist/module/Voicemail/BroadworksBackendConnector.js +3 -0
  146. package/dist/module/Voicemail/UcmBackendConnector.js +6 -0
  147. package/dist/module/Voicemail/WxCallBackendConnector.js +8 -0
  148. package/dist/module/common/Utils.js +22 -8
  149. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  150. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  151. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  152. package/dist/types/CallingClient/CallingClient.d.ts +12 -1
  153. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  154. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  155. package/dist/types/CallingClient/calling/types.d.ts +2 -1
  156. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  157. package/dist/types/CallingClient/constants.d.ts +7 -4
  158. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  159. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  160. package/dist/types/CallingClient/registration/webWorker.d.ts +2 -1
  161. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
  162. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts +2 -4
  163. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts.map +1 -1
  164. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  165. package/dist/types/Contacts/constants.d.ts +1 -1
  166. package/dist/types/Contacts/constants.d.ts.map +1 -1
  167. package/dist/types/Metrics/index.d.ts.map +1 -1
  168. package/dist/types/Metrics/types.d.ts +17 -2
  169. package/dist/types/Metrics/types.d.ts.map +1 -1
  170. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  171. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  172. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  173. package/dist/types/common/Utils.d.ts.map +1 -1
  174. package/package.json +9 -7
@@ -34,9 +34,9 @@ var _callingClientFixtures = require("./callingClientFixtures");
34
34
  var _line = _interopRequireDefault(require("./line"));
35
35
  var _registerFixtures = require("./registration/registerFixtures");
36
36
  var _constants2 = require("../common/constants");
37
+ var _types4 = require("../Metrics/types");
37
38
  var _windowsChromiumIceWarmupUtils = _interopRequireDefault(require("./windowsChromiumIceWarmupUtils"));
38
- function _getRequireWildcardCache(e) { if ("function" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
39
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
39
+ 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); }
40
40
  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; }
41
41
  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 dot-notation */
42
42
  global.crypto = {
@@ -54,7 +54,8 @@ describe('CallingClient Tests', function () {
54
54
  webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
55
55
  var defaultServiceIndicator = _types2.ServiceIndicator.CALLING;
56
56
  var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
57
- var logSpy = jest.spyOn(_Logger.default, 'info');
57
+ var infoSpy = jest.spyOn(_Logger.default, 'info');
58
+ var logSpy = jest.spyOn(_Logger.default, 'log');
58
59
  var warnSpy = jest.spyOn(_Logger.default, 'warn');
59
60
  var originalProcessNextTick = process.nextTick;
60
61
  function flushPromises() {
@@ -68,7 +69,7 @@ describe('CallingClient Tests', function () {
68
69
  webex.internal.services['_serviceUrls']['mobius'] = 'https://mobius.aintgen-a-1.int.infra.webex.com/api/v1';
69
70
  webex.internal.services['_hostCatalog'] = _callingClientFixtures.mockCatalogUS;
70
71
  });
71
- it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
72
+ it('should set mobiusServiceHost correctly when URL is valid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
72
73
  var urlSpy, callingClient;
73
74
  return _regenerator.default.wrap(function _callee$(_context) {
74
75
  while (1) switch (_context.prev = _context.next) {
@@ -95,7 +96,7 @@ describe('CallingClient Tests', function () {
95
96
  }
96
97
  }, _callee);
97
98
  })));
98
- it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
99
+ it('should use default mobius service host when Service URL is invalid', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
99
100
  var callingClient;
100
101
  return _regenerator.default.wrap(function _callee2$(_context2) {
101
102
  while (1) switch (_context2.prev = _context2.next) {
@@ -130,11 +131,11 @@ describe('CallingClient Tests', function () {
130
131
  * No input sdk config to callingClient, it should default to service type
131
132
  * calling and empty domain value.
132
133
  */
133
- it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
134
+ it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
134
135
  return _regenerator.default.wrap(function _callee4$(_context4) {
135
136
  while (1) switch (_context4.prev = _context4.next) {
136
137
  case 0:
137
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
138
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
138
139
  return _regenerator.default.wrap(function _callee3$(_context3) {
139
140
  while (1) switch (_context3.prev = _context3.next) {
140
141
  case 0:
@@ -163,7 +164,7 @@ describe('CallingClient Tests', function () {
163
164
  * It should default to service type calling and empty domain value.
164
165
  *
165
166
  */
166
- it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
167
+ it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
167
168
  var serviceDataObj;
168
169
  return _regenerator.default.wrap(function _callee6$(_context6) {
169
170
  while (1) switch (_context6.prev = _context6.next) {
@@ -173,7 +174,7 @@ describe('CallingClient Tests', function () {
173
174
  indicator: '',
174
175
  domain: ''
175
176
  };
176
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
177
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
177
178
  return _regenerator.default.wrap(function _callee5$(_context5) {
178
179
  while (1) switch (_context5.prev = _context5.next) {
179
180
  case 0:
@@ -205,7 +206,7 @@ describe('CallingClient Tests', function () {
205
206
  *
206
207
  * INDICATOR value MUST MATCH with one of the values in ServiceIndicator enum.
207
208
  */
208
- it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
209
+ it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
209
210
  var serviceDataObj;
210
211
  return _regenerator.default.wrap(function _callee7$(_context7) {
211
212
  while (1) switch (_context7.prev = _context7.next) {
@@ -246,7 +247,7 @@ describe('CallingClient Tests', function () {
246
247
  * DOMAIN field for service type calling is allowed to be empty but if it carries a non-empty
247
248
  * string then it must be of valid domain type.
248
249
  */
249
- it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
250
+ it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
250
251
  var serviceDataObj;
251
252
  return _regenerator.default.wrap(function _callee8$(_context8) {
252
253
  while (1) switch (_context8.prev = _context8.next) {
@@ -285,16 +286,16 @@ describe('CallingClient Tests', function () {
285
286
  *
286
287
  * DOMAIN field for service type 'calling' is allowed to be empty.
287
288
  */
288
- it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
289
+ it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
289
290
  var serviceDataObj;
290
- return _regenerator.default.wrap(function _callee10$(_context10) {
291
- while (1) switch (_context10.prev = _context10.next) {
291
+ return _regenerator.default.wrap(function _callee0$(_context0) {
292
+ while (1) switch (_context0.prev = _context0.next) {
292
293
  case 0:
293
294
  serviceDataObj = {
294
295
  indicator: _types2.ServiceIndicator.CALLING,
295
296
  domain: ''
296
297
  };
297
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
298
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
298
299
  return _regenerator.default.wrap(function _callee9$(_context9) {
299
300
  while (1) switch (_context9.prev = _context9.next) {
300
301
  case 0:
@@ -313,9 +314,9 @@ describe('CallingClient Tests', function () {
313
314
  }))).not.toThrow(Error);
314
315
  case 2:
315
316
  case "end":
316
- return _context10.stop();
317
+ return _context0.stop();
317
318
  }
318
- }, _callee10);
319
+ }, _callee0);
319
320
  })));
320
321
 
321
322
  /**
@@ -326,35 +327,35 @@ describe('CallingClient Tests', function () {
326
327
  *
327
328
  * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
328
329
  */
329
- it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
330
+ it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
330
331
  var serviceDataObj;
331
- return _regenerator.default.wrap(function _callee11$(_context11) {
332
- while (1) switch (_context11.prev = _context11.next) {
332
+ return _regenerator.default.wrap(function _callee1$(_context1) {
333
+ while (1) switch (_context1.prev = _context1.next) {
333
334
  case 0:
334
335
  serviceDataObj = {
335
336
  indicator: _types2.ServiceIndicator.CONTACT_CENTER,
336
337
  domain: ''
337
338
  };
338
- _context11.prev = 1;
339
- _context11.next = 4;
339
+ _context1.prev = 1;
340
+ _context1.next = 4;
340
341
  return (0, _CallingClient.createClient)(webex, {
341
342
  serviceData: serviceDataObj
342
343
  });
343
344
  case 4:
344
- callingClient = _context11.sent;
345
- _context11.next = 10;
345
+ callingClient = _context1.sent;
346
+ _context1.next = 10;
346
347
  break;
347
348
  case 7:
348
- _context11.prev = 7;
349
- _context11.t0 = _context11["catch"](1);
350
- expect(_context11.t0.message).toEqual('Invalid service domain.');
349
+ _context1.prev = 7;
350
+ _context1.t0 = _context1["catch"](1);
351
+ expect(_context1.t0.message).toEqual('Invalid service domain.');
351
352
  case 10:
352
353
  expect.assertions(1);
353
354
  case 11:
354
355
  case "end":
355
- return _context11.stop();
356
+ return _context1.stop();
356
357
  }
357
- }, _callee11, null, [[1, 7]]);
358
+ }, _callee1, null, [[1, 7]]);
358
359
  })));
359
360
 
360
361
  /**
@@ -365,58 +366,58 @@ describe('CallingClient Tests', function () {
365
366
  *
366
367
  * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
367
368
  */
368
- it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
369
+ it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
369
370
  var serviceDataObj;
370
- return _regenerator.default.wrap(function _callee13$(_context13) {
371
- while (1) switch (_context13.prev = _context13.next) {
371
+ return _regenerator.default.wrap(function _callee11$(_context11) {
372
+ while (1) switch (_context11.prev = _context11.next) {
372
373
  case 0:
373
374
  serviceDataObj = {
374
375
  indicator: _types2.ServiceIndicator.CONTACT_CENTER,
375
376
  domain: 'test.example.com'
376
377
  };
377
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
378
- return _regenerator.default.wrap(function _callee12$(_context12) {
379
- while (1) switch (_context12.prev = _context12.next) {
378
+ expect(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
379
+ return _regenerator.default.wrap(function _callee10$(_context10) {
380
+ while (1) switch (_context10.prev = _context10.next) {
380
381
  case 0:
381
- _context12.next = 2;
382
+ _context10.next = 2;
382
383
  return (0, _CallingClient.createClient)(webex, {
383
384
  serviceData: serviceDataObj
384
385
  });
385
386
  case 2:
386
- callingClient = _context12.sent;
387
+ callingClient = _context10.sent;
387
388
  expect(callingClient).toBeTruthy();
388
389
  case 4:
389
390
  case "end":
390
- return _context12.stop();
391
+ return _context10.stop();
391
392
  }
392
- }, _callee12);
393
+ }, _callee10);
393
394
  }))).not.toThrow(Error);
394
395
  case 2:
395
396
  case "end":
396
- return _context13.stop();
397
+ return _context11.stop();
397
398
  }
398
- }, _callee13);
399
+ }, _callee11);
399
400
  })));
400
- it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
401
- return _regenerator.default.wrap(function _callee14$(_context14) {
402
- while (1) switch (_context14.prev = _context14.next) {
401
+ it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
402
+ return _regenerator.default.wrap(function _callee12$(_context12) {
403
+ while (1) switch (_context12.prev = _context12.next) {
403
404
  case 0:
404
- _context14.next = 2;
405
+ _context12.next = 2;
405
406
  return (0, _CallingClient.createClient)(webex, {
406
407
  logger: {
407
408
  level: _types.LOGGER.INFO
408
409
  }
409
410
  });
410
411
  case 2:
411
- callingClient = _context14.sent;
412
+ callingClient = _context12.sent;
412
413
  expect(callingClient).toBeTruthy();
413
414
  expect(callingClient.getLoggingLevel).toBeTruthy();
414
415
  expect(callingClient.getLoggingLevel()).toEqual(_types.LOGGER.INFO);
415
416
  case 6:
416
417
  case "end":
417
- return _context14.stop();
418
+ return _context12.stop();
418
419
  }
419
- }, _callee14);
420
+ }, _callee12);
420
421
  })));
421
422
  });
422
423
  describe('Mobius Server discovery tests', function () {
@@ -429,19 +430,19 @@ describe('CallingClient Tests', function () {
429
430
  callingClient = undefined;
430
431
  jest.useRealTimers();
431
432
  });
432
- it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
433
- return _regenerator.default.wrap(function _callee15$(_context15) {
434
- while (1) switch (_context15.prev = _context15.next) {
433
+ it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
434
+ return _regenerator.default.wrap(function _callee13$(_context13) {
435
+ while (1) switch (_context13.prev = _context13.next) {
435
436
  case 0:
436
437
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
437
- _context15.next = 3;
438
+ _context13.next = 3;
438
439
  return (0, _CallingClient.createClient)(webex, {
439
440
  logger: {
440
441
  level: _types.LOGGER.INFO
441
442
  }
442
443
  });
443
444
  case 3:
444
- callingClient = _context15.sent;
445
+ callingClient = _context13.sent;
445
446
  expect(webex.request).toBeCalledTimes(3);
446
447
  expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
447
448
  expect(handleErrorSpy).not.toBeCalled();
@@ -463,27 +464,27 @@ describe('CallingClient Tests', function () {
463
464
  }));
464
465
  case 10:
465
466
  case "end":
466
- return _context15.stop();
467
+ return _context13.stop();
467
468
  }
468
- }, _callee15);
469
+ }, _callee13);
469
470
  })));
470
- it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
471
+ it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
471
472
  var failurePayload;
472
- return _regenerator.default.wrap(function _callee16$(_context16) {
473
- while (1) switch (_context16.prev = _context16.next) {
473
+ return _regenerator.default.wrap(function _callee14$(_context14) {
474
+ while (1) switch (_context14.prev = _context14.next) {
474
475
  case 0:
475
476
  failurePayload = {
476
477
  statusCode: 500
477
478
  };
478
479
  webex.request.mockRejectedValue(failurePayload);
479
- _context16.next = 4;
480
+ _context14.next = 4;
480
481
  return (0, _CallingClient.createClient)(webex, {
481
482
  logger: {
482
483
  level: _types.LOGGER.INFO
483
484
  }
484
485
  });
485
486
  case 4:
486
- callingClient = _context16.sent;
487
+ callingClient = _context14.sent;
487
488
  expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
488
489
  uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
489
490
  method: 'GET'
@@ -505,30 +506,33 @@ describe('CallingClient Tests', function () {
505
506
  method: 'getMobiusServers'
506
507
  });
507
508
  expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
508
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
509
+ expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
510
+ file: _constants.CALLING_CLIENT_FILE,
511
+ method: 'getMobiusServers'
512
+ }));
509
513
  case 12:
510
514
  case "end":
511
- return _context16.stop();
515
+ return _context14.stop();
512
516
  }
513
- }, _callee16);
517
+ }, _callee14);
514
518
  })));
515
- it('case when /myIP failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
519
+ it('case when /myIP failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
516
520
  var failurePayload;
517
- return _regenerator.default.wrap(function _callee17$(_context17) {
518
- while (1) switch (_context17.prev = _context17.next) {
521
+ return _regenerator.default.wrap(function _callee15$(_context15) {
522
+ while (1) switch (_context15.prev = _context15.next) {
519
523
  case 0:
520
524
  failurePayload = {
521
525
  statusCode: 401
522
526
  };
523
527
  webex.request.mockRejectedValueOnce(failurePayload);
524
- _context17.next = 4;
528
+ _context15.next = 4;
525
529
  return (0, _CallingClient.createClient)(webex, {
526
530
  logger: {
527
531
  level: _types.LOGGER.INFO
528
532
  }
529
533
  });
530
534
  case 4:
531
- callingClient = _context17.sent;
535
+ callingClient = _context15.sent;
532
536
  expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
533
537
  uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
534
538
  method: 'GET'
@@ -538,30 +542,33 @@ describe('CallingClient Tests', function () {
538
542
  method: 'getMobiusServers'
539
543
  });
540
544
  expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
541
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
545
+ expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
546
+ file: _constants.CALLING_CLIENT_FILE,
547
+ method: 'getMobiusServers'
548
+ }));
542
549
  case 9:
543
550
  case "end":
544
- return _context17.stop();
551
+ return _context15.stop();
545
552
  }
546
- }, _callee17);
553
+ }, _callee15);
547
554
  })));
548
- it('when region discovery succeeds but region based mobius url discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
555
+ it('when region discovery succeeds but region based mobius url discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
549
556
  var failurePayload;
550
- return _regenerator.default.wrap(function _callee18$(_context18) {
551
- while (1) switch (_context18.prev = _context18.next) {
557
+ return _regenerator.default.wrap(function _callee16$(_context16) {
558
+ while (1) switch (_context16.prev = _context16.next) {
552
559
  case 0:
553
560
  failurePayload = {
554
561
  statusCode: 500
555
562
  };
556
563
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockRejectedValueOnce(failurePayload);
557
- _context18.next = 4;
564
+ _context16.next = 4;
558
565
  return (0, _CallingClient.createClient)(webex, {
559
566
  logger: {
560
567
  level: _types.LOGGER.INFO
561
568
  }
562
569
  });
563
570
  case 4:
564
- callingClient = _context18.sent;
571
+ callingClient = _context16.sent;
565
572
  expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
566
573
  file: _constants.CALLING_CLIENT_FILE,
567
574
  method: 'getMobiusServers'
@@ -579,30 +586,33 @@ describe('CallingClient Tests', function () {
579
586
  addAuthHeader: false,
580
587
  headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
581
588
  });
582
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
589
+ expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
590
+ file: _constants.CALLING_CLIENT_FILE,
591
+ method: 'getMobiusServers'
592
+ }));
583
593
  case 11:
584
594
  case "end":
585
- return _context18.stop();
595
+ return _context16.stop();
586
596
  }
587
- }, _callee18);
597
+ }, _callee16);
588
598
  })));
589
- it('case when discovery failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
599
+ it('case when discovery failed with 401', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
590
600
  var failurePayload;
591
- return _regenerator.default.wrap(function _callee19$(_context19) {
592
- while (1) switch (_context19.prev = _context19.next) {
601
+ return _regenerator.default.wrap(function _callee17$(_context17) {
602
+ while (1) switch (_context17.prev = _context17.next) {
593
603
  case 0:
594
604
  failurePayload = {
595
605
  statusCode: 401
596
606
  };
597
607
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockRejectedValueOnce(failurePayload);
598
- _context19.next = 4;
608
+ _context17.next = 4;
599
609
  return (0, _CallingClient.createClient)(webex, {
600
610
  logger: {
601
611
  level: _types.LOGGER.INFO
602
612
  }
603
613
  });
604
614
  case 4:
605
- callingClient = _context19.sent;
615
+ callingClient = _context17.sent;
606
616
  expect(webex.request).toBeCalledTimes(2);
607
617
  expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
608
618
  uri: 'https://mobius-us-east-1.prod.infra.webex.com/api/v1/calling/web/myip',
@@ -619,22 +629,23 @@ describe('CallingClient Tests', function () {
619
629
  method: 'getMobiusServers'
620
630
  });
621
631
  expect(callingClient.primaryMobiusUris).toEqual(["".concat(callingClient['mobiusHost']).concat(_constants.URL_ENDPOINT)]);
622
- expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", '');
632
+ expect(warnSpy).toBeCalledWith("Couldn't resolve the region and country code. Defaulting to the catalog entries to discover mobius servers", expect.objectContaining({
633
+ file: _constants.CALLING_CLIENT_FILE,
634
+ method: 'getMobiusServers'
635
+ }));
623
636
  case 11:
624
637
  case "end":
625
- return _context19.stop();
638
+ return _context17.stop();
626
639
  }
627
- }, _callee19);
640
+ }, _callee17);
628
641
  })));
629
- it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
630
- var infoSpy;
631
- return _regenerator.default.wrap(function _callee20$(_context20) {
632
- while (1) switch (_context20.prev = _context20.next) {
642
+ it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
643
+ return _regenerator.default.wrap(function _callee18$(_context18) {
644
+ while (1) switch (_context18.prev = _context18.next) {
633
645
  case 0:
634
- infoSpy = jest.spyOn(_Logger.default, 'info');
635
646
  infoSpy.mockReset();
636
647
  webex.request.mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
637
- _context20.next = 5;
648
+ _context18.next = 4;
638
649
  return (0, _CallingClient.createClient)(webex, {
639
650
  discovery: {
640
651
  region: 'AP-SOUTHEAST',
@@ -644,8 +655,8 @@ describe('CallingClient Tests', function () {
644
655
  level: _types.LOGGER.INFO
645
656
  }
646
657
  });
647
- case 5:
648
- callingClient = _context20.sent;
658
+ case 4:
659
+ callingClient = _context18.sent;
649
660
  expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
650
661
  expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
651
662
  file: 'CallingClient',
@@ -656,335 +667,377 @@ describe('CallingClient Tests', function () {
656
667
  method: 'GET'
657
668
  }));
658
669
  expect(handleErrorSpy).not.toHaveBeenCalled();
659
- case 10:
670
+ case 9:
660
671
  case "end":
661
- return _context20.stop();
672
+ return _context18.stop();
662
673
  }
663
- }, _callee20);
674
+ }, _callee18);
664
675
  })));
665
676
  });
666
677
  describe('Testing each cluster present withing host catalog', function () {
667
678
  var mobiusCluster = ['mobius-eu-central-1.prod.infra.webex.com', 'mobius-us-east-1.int.infra.webex.com', 'mobius-eu-central-1.int.infra.webex.com'];
668
679
  var checkCluster = /*#__PURE__*/function () {
669
- var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(mockServiceHosts, mockCatalog) {
680
+ var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(mockServiceHosts, mockCatalog) {
670
681
  var callingClient;
671
- return _regenerator.default.wrap(function _callee21$(_context21) {
672
- while (1) switch (_context21.prev = _context21.next) {
682
+ return _regenerator.default.wrap(function _callee19$(_context19) {
683
+ while (1) switch (_context19.prev = _context19.next) {
673
684
  case 0:
674
685
  webex.internal.services._hostCatalog = mockCatalog;
675
- _context21.next = 3;
686
+ _context19.next = 3;
676
687
  return (0, _CallingClient.createClient)(webex, {
677
688
  logger: {
678
689
  level: _types.LOGGER.INFO
679
690
  }
680
691
  });
681
692
  case 3:
682
- callingClient = _context21.sent;
693
+ callingClient = _context19.sent;
683
694
  expect(callingClient['mobiusClusters']).toStrictEqual(mockServiceHosts);
684
695
  case 5:
685
696
  case "end":
686
- return _context21.stop();
697
+ return _context19.stop();
687
698
  }
688
- }, _callee21);
699
+ }, _callee19);
689
700
  }));
690
701
  return function checkCluster(_x, _x2) {
691
- return _ref21.apply(this, arguments);
702
+ return _ref19.apply(this, arguments);
692
703
  };
693
704
  }();
694
705
  it.each(mobiusCluster)('%s', /*#__PURE__*/function () {
695
- var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(clusterName) {
696
- return _regenerator.default.wrap(function _callee22$(_context22) {
697
- while (1) switch (_context22.prev = _context22.next) {
706
+ var _ref20 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(clusterName) {
707
+ return _regenerator.default.wrap(function _callee20$(_context20) {
708
+ while (1) switch (_context20.prev = _context20.next) {
698
709
  case 0:
699
- _context22.t0 = clusterName;
700
- _context22.next = _context22.t0 === 'mobius-eu-central-1.prod.infra.webex.com' ? 3 : _context22.t0 === 'mobius-us-east-1.int.infra.webex.com' ? 5 : _context22.t0 === 'mobius-eu-central-1.int.infra.webex.com' ? 7 : 9;
710
+ _context20.t0 = clusterName;
711
+ _context20.next = _context20.t0 === 'mobius-eu-central-1.prod.infra.webex.com' ? 3 : _context20.t0 === 'mobius-us-east-1.int.infra.webex.com' ? 5 : _context20.t0 === 'mobius-eu-central-1.int.infra.webex.com' ? 7 : 9;
701
712
  break;
702
713
  case 3:
703
714
  checkCluster(_callingClientFixtures.mockEUServiceHosts, _callingClientFixtures.mockCatalogEU);
704
- return _context22.abrupt("break", 10);
715
+ return _context20.abrupt("break", 10);
705
716
  case 5:
706
717
  checkCluster(_callingClientFixtures.mockIntServiceHosts, _callingClientFixtures.mockCatalogUSInt);
707
- return _context22.abrupt("break", 10);
718
+ return _context20.abrupt("break", 10);
708
719
  case 7:
709
720
  checkCluster(_callingClientFixtures.mockEUIntServiceHosts, _callingClientFixtures.mockCatalogEUInt);
710
- return _context22.abrupt("break", 10);
721
+ return _context20.abrupt("break", 10);
711
722
  case 9:
712
- return _context22.abrupt("break", 10);
723
+ return _context20.abrupt("break", 10);
713
724
  case 10:
714
725
  case "end":
715
- return _context22.stop();
726
+ return _context20.stop();
716
727
  }
717
- }, _callee22);
728
+ }, _callee20);
718
729
  }));
719
730
  return function (_x3) {
720
- return _ref22.apply(this, arguments);
731
+ return _ref20.apply(this, arguments);
721
732
  };
722
733
  }());
723
734
  });
724
- describe('Network activity detection tests', function () {
735
+ describe('Line creation tests', function () {
736
+ var callingClient;
737
+ var line;
738
+ beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
739
+ return _regenerator.default.wrap(function _callee21$(_context21) {
740
+ while (1) switch (_context21.prev = _context21.next) {
741
+ case 0:
742
+ _context21.next = 2;
743
+ return (0, _CallingClient.createClient)(webex);
744
+ case 2:
745
+ callingClient = _context21.sent;
746
+ line = (0, _values.default)(callingClient.lineDict)[0];
747
+ case 4:
748
+ case "end":
749
+ return _context21.stop();
750
+ }
751
+ }, _callee21);
752
+ })));
753
+ afterEach(function () {
754
+ jest.clearAllTimers();
755
+ jest.clearAllMocks();
756
+ callingClient.removeAllListeners();
757
+ callManager.removeAllListeners();
758
+ callingClient = undefined;
759
+ jest.useRealTimers();
760
+ });
761
+ it('verify line dict successfully created', function () {
762
+ expect(callingClient.lineDict).toBeTruthy();
763
+ expect(line).toBeTruthy();
764
+ expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
765
+ });
766
+ it('verify getLines response', function () {
767
+ expect(callingClient.getLines).toBeTruthy();
768
+ expect(callingClient.getLines()).toEqual(callingClient.lineDict);
769
+ });
770
+ });
771
+ describe('Connectivity and Mercury event handlers', function () {
725
772
  var callingClient;
726
773
  var line;
727
774
  var reg;
728
- var restoreSpy;
729
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
775
+ var windowEventSpy;
730
776
  var deRegSpy;
777
+ var restoreSpy;
731
778
  var restartRegisterSpy;
732
779
  var registerSpy;
733
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
734
- return _regenerator.default.wrap(function _callee23$(_context23) {
735
- while (1) switch (_context23.prev = _context23.next) {
780
+ var metricSpy;
781
+ beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
782
+ return _regenerator.default.wrap(function _callee22$(_context22) {
783
+ while (1) switch (_context22.prev = _context22.next) {
736
784
  case 0:
737
785
  jest.useFakeTimers();
738
786
  webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload).mockResolvedValueOnce(_callingClientFixtures.registrationPayload);
739
- _context23.next = 4;
787
+ windowEventSpy = jest.spyOn(window, 'addEventListener');
788
+ _context22.next = 5;
740
789
  return (0, _CallingClient.createClient)(webex, {
741
790
  logger: {
742
791
  level: _types.LOGGER.INFO
743
792
  }
744
793
  });
745
- case 4:
746
- callingClient = _context23.sent;
794
+ case 5:
795
+ callingClient = _context22.sent;
747
796
  line = (0, _values.default)(callingClient.lineDict)[0];
748
797
  reg = line.registration;
749
- _context23.next = 9;
798
+ _context22.next = 10;
750
799
  return line.register();
751
- case 9:
752
- deRegSpy = jest.spyOn(line.registration, 'deregister');
800
+ case 10:
801
+ deRegSpy = jest.spyOn(reg, 'deregister');
753
802
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
754
803
  restartRegisterSpy = jest.spyOn(reg, 'restartRegistration');
755
804
  registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
756
- case 13:
805
+ metricSpy = jest.spyOn(callingClient['metricManager'], 'submitConnectionMetrics');
806
+ case 15:
757
807
  case "end":
758
- return _context23.stop();
808
+ return _context22.stop();
759
809
  }
760
- }, _callee23);
810
+ }, _callee22);
761
811
  })));
762
812
  afterEach(function () {
763
813
  jest.clearAllTimers();
764
814
  jest.clearAllMocks();
765
815
  callingClient.removeAllListeners();
816
+ callingClient['callManager'].callCollection = {};
766
817
  callManager.removeAllListeners();
767
818
  callingClient = undefined;
768
819
  jest.useRealTimers();
769
820
  });
770
- it('detect a network flap in mercury connection', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
771
- return _regenerator.default.wrap(function _callee24$(_context24) {
772
- while (1) switch (_context24.prev = _context24.next) {
821
+ it('window offline handler sets networkDown and clears keepalive when network is unreachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
822
+ var g, clearKeepaliveSpy, offlineCb;
823
+ return _regenerator.default.wrap(function _callee23$(_context23) {
824
+ while (1) switch (_context23.prev = _context23.next) {
773
825
  case 0:
774
- warnSpy.mockClear();
775
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
776
-
777
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
778
- webex.internal.mercury.connected = false;
779
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
780
-
781
- /* We should be detecting the network flap */
782
- expect(warnSpy).toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
826
+ g = global;
827
+ g.fetch = jest.fn().mockRejectedValueOnce(new Error('network fail'));
828
+ clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
829
+ offlineCb = windowEventSpy.mock.calls[1][1];
830
+ _context23.next = 6;
831
+ return offlineCb();
832
+ case 6:
833
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Network connectivity probe failed'), {
783
834
  file: _constants.CALLING_CLIENT_FILE,
784
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
835
+ method: 'pingExternal'
785
836
  });
786
-
787
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
788
- webex.internal.mercury.connected = true;
789
- logSpy.mockReset();
790
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
791
- _context24.next = 10;
792
- return flushPromises();
793
- case 10:
794
- _Logger.default.info('Mercury connection is up again, re-registering with Webex Calling if needed', {
795
- file: _constants.REGISTRATION_FILE,
796
- method: 'handleConnectionRestoration'
797
- });
798
-
799
- /* We should be detecting the network recovery */
800
- expect(logSpy).toHaveBeenCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
801
- file: _constants.REGISTRATION_FILE,
802
- method: 'handleConnectionRestoration'
803
- });
804
- expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
805
- expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
806
- expect(webex.request).toHaveBeenCalledTimes(6);
807
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
808
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
809
- case 17:
837
+ expect(callingClient['isNetworkDown']).toBe(true);
838
+ expect(clearKeepaliveSpy).toHaveBeenCalled();
839
+ case 9:
840
+ case "end":
841
+ return _context23.stop();
842
+ }
843
+ }, _callee23);
844
+ })));
845
+ it('window offline handler does not clear keepalive when network is reachable', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
846
+ var g, clearKeepaliveSpy, offlineCb;
847
+ return _regenerator.default.wrap(function _callee24$(_context24) {
848
+ while (1) switch (_context24.prev = _context24.next) {
849
+ case 0:
850
+ g = global;
851
+ g.fetch = jest.fn().mockResolvedValueOnce({});
852
+ clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
853
+ offlineCb = windowEventSpy.mock.calls[1][1];
854
+ _context24.next = 6;
855
+ return offlineCb();
856
+ case 6:
857
+ expect(g.fetch).toHaveBeenCalledWith('https://www.google.com/generate_204', expect.any(Object));
858
+ expect(callingClient['isNetworkDown']).toBe(false);
859
+ expect(clearKeepaliveSpy).not.toHaveBeenCalled();
860
+ case 9:
810
861
  case "end":
811
862
  return _context24.stop();
812
863
  }
813
864
  }, _callee24);
814
865
  })));
815
- it('Simulate a network flap with no active calls and re-verify registration: Restore Failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
816
- var failurePayload, mockRegistrationBody, successPayload;
866
+ it('window online handler sets networkUpTimestamp and logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
867
+ var onlineCb;
817
868
  return _regenerator.default.wrap(function _callee25$(_context25) {
818
869
  while (1) switch (_context25.prev = _context25.next) {
819
870
  case 0:
820
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
821
- failurePayload = {
822
- statusCode: 500,
823
- body: ''
824
- };
825
- mockRegistrationBody = (0, _testUtil.getMockDeviceInfo)();
826
- successPayload = {
827
- statusCode: 200,
828
- body: mockRegistrationBody
829
- };
830
- webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
831
-
832
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
833
- webex.internal.mercury.connected = false;
834
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
835
-
836
- /* We should be detecting the network flap */
837
- expect(warnSpy).toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
871
+ onlineCb = windowEventSpy.mock.calls[0][1];
872
+ _context25.next = 3;
873
+ return onlineCb();
874
+ case 3:
875
+ expect(callingClient['networkUpTimestamp']).toEqual(expect.any(String));
876
+ expect(infoSpy).toHaveBeenCalledWith(_constants2.METHOD_START_MESSAGE, {
838
877
  file: _constants.CALLING_CLIENT_FILE,
839
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
878
+ method: 'handleNetworkOnline'
840
879
  });
841
-
842
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
843
- webex.internal.mercury.connected = true;
844
- logSpy.mockReset();
845
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
846
- _context25.next = 13;
847
- return flushPromises();
848
- case 13:
849
- _Logger.default.info('Mercury connection is up again, re-registering with Webex Calling if needed', {
850
- file: _constants.REGISTRATION_FILE,
851
- method: 'handleConnectionRestoration'
852
- });
853
-
854
- /* We should be detecting the network recovery */
855
- expect(logSpy).toBeCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
856
- file: _constants.REGISTRATION_FILE,
857
- method: 'handleConnectionRestoration'
858
- });
859
- expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
860
- expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
861
- expect(webex.request).toHaveBeenCalledTimes(6);
862
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
863
- expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
864
- case 20:
880
+ case 5:
865
881
  case "end":
866
882
  return _context25.stop();
867
883
  }
868
884
  }, _callee25);
869
885
  })));
870
- it('Simulate a network flap before initial registration is done', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
871
- var handleConnectionRestoreSpy;
886
+ it('mercury offline submits metrics and sets timestamp', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
887
+ var mercuryOfflineCb;
872
888
  return _regenerator.default.wrap(function _callee26$(_context26) {
873
889
  while (1) switch (_context26.prev = _context26.next) {
874
890
  case 0:
875
- warnSpy.mockClear();
876
- handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
877
- reg.setStatus(_types2.RegistrationStatus.IDLE);
878
-
879
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
880
- webex.internal.mercury.connected = false;
881
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
882
-
883
- /* We should be detecting the network flap */
884
- expect(warnSpy).toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
891
+ mercuryOfflineCb = webex.internal.mercury.on.mock.calls[1][1];
892
+ _context26.next = 3;
893
+ return mercuryOfflineCb();
894
+ case 3:
895
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mercury down, waiting for connection to be up'), {
885
896
  file: _constants.CALLING_CLIENT_FILE,
886
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
887
- });
888
-
889
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
890
- webex.internal.mercury.connected = true;
891
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
892
- _context26.next = 10;
893
- return flushPromises();
894
- case 10:
895
- /* We should be detecting the network recovery */
896
- expect(logSpy).not.toBeCalledWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
897
- file: _constants.REGISTRATION_FILE,
898
- method: 'handleConnectionRestoration'
897
+ method: 'handleMercuryOffline'
899
898
  });
900
-
901
- /*
902
- * When initial registration is not done, network flap
903
- * will not trigger de-registration/registration
904
- */
905
- expect(handleConnectionRestoreSpy).not.toBeCalledOnceWith();
906
- case 12:
899
+ expect(callingClient['mercuryDownTimestamp']).toEqual(expect.any(String));
900
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_DOWN, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), '');
901
+ case 6:
907
902
  case "end":
908
903
  return _context26.stop();
909
904
  }
910
905
  }, _callee26);
911
906
  })));
912
- it('Simulate a network flap with 1 active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
907
+ it('handles reconnection with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
908
+ var handleConnectionRestoreSpy, mercuryOnlineCb;
913
909
  return _regenerator.default.wrap(function _callee27$(_context27) {
914
910
  while (1) switch (_context27.prev = _context27.next) {
915
911
  case 0:
916
- expect(line.getStatus()).toEqual(_types2.RegistrationStatus.ACTIVE);
917
-
918
- /** create a new call */
919
- reg.callManager.createCall();
920
- expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
921
-
922
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
923
- webex.internal.mercury.connected = false;
924
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
912
+ handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
913
+ callingClient['isNetworkDown'] = true;
914
+ callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
915
+ callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
916
+ mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
925
917
  _context27.next = 7;
926
- return flushPromises();
918
+ return mercuryOnlineCb();
927
919
  case 7:
928
- /* We should be detecting the network flap */
929
- expect(warnSpy).not.toBeCalledOnceWith('Network has flapped, waiting for mercury connection to be up', {
930
- file: _constants.CALLING_CLIENT_FILE,
931
- method: 'handleConnectionRestoration'
932
- });
933
-
934
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
935
- webex.internal.mercury.connected = true;
936
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
937
- _context27.next = 12;
920
+ // Run the interval once
921
+ jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
922
+ _context27.next = 10;
938
923
  return flushPromises();
939
- case 12:
940
- /* We should be detecting the network recovery */
941
- expect(logSpy).not.toBeCalledOnceWith('Mercury connection is up again, re-registering with Webex Calling if needed', {
924
+ case 10:
925
+ expect(handleConnectionRestoreSpy).toHaveBeenCalledWith(true);
926
+ expect(logSpy).toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
942
927
  file: _constants.REGISTRATION_FILE,
943
928
  method: 'handleConnectionRestoration'
944
929
  });
945
- expect(registerSpy).not.toBeCalledWith(true);
946
- case 14:
930
+ expect(deRegSpy).toHaveBeenCalledWith();
931
+ expect(restoreSpy).toHaveBeenCalledWith('handleConnectionRestoration');
932
+ expect(restartRegisterSpy).toHaveBeenCalledWith('handleConnectionRestoration');
933
+ expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
934
+ expect(registerSpy).toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
935
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
936
+ case 18:
947
937
  case "end":
948
938
  return _context27.stop();
949
939
  }
950
940
  }, _callee27);
951
941
  })));
952
- });
953
- describe('Line creation tests', function () {
954
- var callingClient;
955
- var line;
956
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
942
+ it('no reconnection for idle registration with no active calls after network flap, once mercury comes back up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
943
+ var handleConnectionRestoreSpy, mercuryOnlineCb;
957
944
  return _regenerator.default.wrap(function _callee28$(_context28) {
958
945
  while (1) switch (_context28.prev = _context28.next) {
959
946
  case 0:
960
- _context28.next = 2;
961
- return (0, _CallingClient.createClient)(webex);
962
- case 2:
963
- callingClient = _context28.sent;
964
- line = (0, _values.default)(callingClient.lineDict)[0];
965
- case 4:
947
+ handleConnectionRestoreSpy = jest.spyOn(reg, 'handleConnectionRestoration');
948
+ callingClient['isNetworkDown'] = true;
949
+ callingClient['networkDownTimestamp'] = '2023-01-01T00:00:00.000Z';
950
+ callingClient['networkUpTimestamp'] = '2023-01-01T00:01:00.000Z';
951
+ reg.setStatus(_types2.RegistrationStatus.IDLE);
952
+ mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
953
+ _context28.next = 8;
954
+ return mercuryOnlineCb();
955
+ case 8:
956
+ // Run the interval once
957
+ jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 100);
958
+ _context28.next = 11;
959
+ return flushPromises();
960
+ case 11:
961
+ expect(handleConnectionRestoreSpy).not.toHaveBeenCalledWith(true);
962
+ expect(logSpy).not.toHaveBeenCalledWith('Network is up again, re-registering with Webex Calling if needed', {
963
+ file: _constants.REGISTRATION_FILE,
964
+ method: 'handleConnectionRestoration'
965
+ });
966
+ expect(deRegSpy).not.toHaveBeenCalledWith();
967
+ expect(restoreSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
968
+ expect(restartRegisterSpy).not.toHaveBeenCalledWith('handleConnectionRestoration');
969
+ expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
970
+ expect(registerSpy).not.toHaveBeenCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
971
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, '2023-01-01T00:00:00.000Z', '2023-01-01T00:01:00.000Z');
972
+ case 19:
966
973
  case "end":
967
974
  return _context28.stop();
968
975
  }
969
976
  }, _callee28);
970
977
  })));
971
- afterEach(function () {
972
- jest.clearAllTimers();
973
- jest.clearAllMocks();
974
- callingClient.removeAllListeners();
975
- callManager.removeAllListeners();
976
- callingClient = undefined;
977
- jest.useRealTimers();
978
- });
979
- it('verify line dict successfully created', function () {
980
- expect(callingClient.lineDict).toBeTruthy();
981
- expect(line).toBeTruthy();
982
- expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
983
- });
984
- it('verify getLines response', function () {
985
- expect(callingClient.getLines).toBeTruthy();
986
- expect(callingClient.getLines()).toEqual(callingClient.lineDict);
987
- });
978
+ it('handle calls status check once mercury comes back up after a network flap', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
979
+ var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
980
+ return _regenerator.default.wrap(function _callee29$(_context29) {
981
+ while (1) switch (_context29.prev = _context29.next) {
982
+ case 0:
983
+ callingClient['isNetworkDown'] = true;
984
+ call = callingClient['callManager'].createCall();
985
+ callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
986
+ deleteSpy = jest.spyOn(call, 'delete');
987
+ expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
988
+ mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
989
+ _context29.next = 8;
990
+ return mercuryOnlineCb();
991
+ case 8:
992
+ expect(callKeepaliveSpy).toHaveBeenCalled();
993
+ _context29.next = 11;
994
+ return flushPromises();
995
+ case 11:
996
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
997
+ file: _constants.CALLING_CLIENT_FILE,
998
+ method: 'checkCallStatus'
999
+ });
1000
+ expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1001
+ expect(deleteSpy).toHaveBeenCalled();
1002
+ expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
1003
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.NETWORK_FLAP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
1004
+ case 16:
1005
+ case "end":
1006
+ return _context29.stop();
1007
+ }
1008
+ }, _callee29);
1009
+ })));
1010
+ it('handle calls status check once mercury comes back up with stable network', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1011
+ var call, callKeepaliveSpy, deleteSpy, mercuryOnlineCb;
1012
+ return _regenerator.default.wrap(function _callee30$(_context30) {
1013
+ while (1) switch (_context30.prev = _context30.next) {
1014
+ case 0:
1015
+ call = callingClient['callManager'].createCall();
1016
+ callKeepaliveSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(new Error('keepalive fail'));
1017
+ deleteSpy = jest.spyOn(call, 'delete');
1018
+ expect((0, _keys.default)(callingClient['callManager'].getActiveCalls()).length).toBe(1);
1019
+ mercuryOnlineCb = webex.internal.mercury.on.mock.calls[2][1];
1020
+ _context30.next = 7;
1021
+ return mercuryOnlineCb();
1022
+ case 7:
1023
+ expect(callKeepaliveSpy).toHaveBeenCalled();
1024
+ _context30.next = 10;
1025
+ return flushPromises();
1026
+ case 10:
1027
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Call Keepalive failed'), {
1028
+ file: _constants.CALLING_CLIENT_FILE,
1029
+ method: 'checkCallStatus'
1030
+ });
1031
+ expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1032
+ expect(deleteSpy).toHaveBeenCalled();
1033
+ expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
1034
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CONNECTION_ERROR, _types4.CONNECTION_ACTION.MERCURY_UP, _types4.METRIC_TYPE.BEHAVIORAL, expect.any(String), expect.any(String));
1035
+ case 15:
1036
+ case "end":
1037
+ return _context30.stop();
1038
+ }
1039
+ }, _callee30);
1040
+ })));
988
1041
  });
989
1042
 
990
1043
  // Calling related test cases
@@ -1001,15 +1054,15 @@ describe('CallingClient Tests', function () {
1001
1054
  });
1002
1055
  var callingClient;
1003
1056
  var line;
1004
- beforeAll( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
1057
+ beforeAll(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1005
1058
  var calls;
1006
- return _regenerator.default.wrap(function _callee29$(_context29) {
1007
- while (1) switch (_context29.prev = _context29.next) {
1059
+ return _regenerator.default.wrap(function _callee31$(_context31) {
1060
+ while (1) switch (_context31.prev = _context31.next) {
1008
1061
  case 0:
1009
- _context29.next = 2;
1062
+ _context31.next = 2;
1010
1063
  return (0, _CallingClient.createClient)(webex);
1011
1064
  case 2:
1012
- callingClient = _context29.sent;
1065
+ callingClient = _context31.sent;
1013
1066
  line = new _line.default(userId, clientDeviceUri, mutex, primaryMobiusUris(), backupMobiusUris(), _types.LOGGER.INFO);
1014
1067
  calls = (0, _values.default)(callManager.getActiveCalls());
1015
1068
  calls.forEach(function (call) {
@@ -1017,9 +1070,9 @@ describe('CallingClient Tests', function () {
1017
1070
  });
1018
1071
  case 6:
1019
1072
  case "end":
1020
- return _context29.stop();
1073
+ return _context31.stop();
1021
1074
  }
1022
- }, _callee29);
1075
+ }, _callee31);
1023
1076
  })));
1024
1077
  afterAll(function () {
1025
1078
  callingClient.removeAllListeners();
@@ -1102,23 +1155,23 @@ describe('CallingClient Tests', function () {
1102
1155
  describe('Call Session Event test', function () {
1103
1156
  var mockOn = webex.internal.mercury.on;
1104
1157
  var callingClient;
1105
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee30() {
1106
- return _regenerator.default.wrap(function _callee30$(_context30) {
1107
- while (1) switch (_context30.prev = _context30.next) {
1158
+ beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1159
+ return _regenerator.default.wrap(function _callee32$(_context32) {
1160
+ while (1) switch (_context32.prev = _context32.next) {
1108
1161
  case 0:
1109
- _context30.next = 2;
1162
+ _context32.next = 2;
1110
1163
  return (0, _CallingClient.createClient)(webex, {
1111
1164
  logger: {
1112
1165
  level: _types.LOGGER.INFO
1113
1166
  }
1114
1167
  });
1115
1168
  case 2:
1116
- callingClient = _context30.sent;
1169
+ callingClient = _context32.sent;
1117
1170
  case 3:
1118
1171
  case "end":
1119
- return _context30.stop();
1172
+ return _context32.stop();
1120
1173
  }
1121
- }, _callee30);
1174
+ }, _callee32);
1122
1175
  })));
1123
1176
  afterEach(function () {
1124
1177
  callingClient.removeAllListeners();
@@ -1219,17 +1272,17 @@ describe('CallingClient Tests', function () {
1219
1272
  afterAll(function () {
1220
1273
  global.RTCPeerConnection = origRTCPeerConnection;
1221
1274
  });
1222
- it('should complete without throwing', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee31() {
1223
- return _regenerator.default.wrap(function _callee31$(_context31) {
1224
- while (1) switch (_context31.prev = _context31.next) {
1275
+ it('should complete without throwing', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
1276
+ return _regenerator.default.wrap(function _callee33$(_context33) {
1277
+ while (1) switch (_context33.prev = _context33.next) {
1225
1278
  case 0:
1226
- _context31.next = 2;
1279
+ _context33.next = 2;
1227
1280
  return expect((0, _windowsChromiumIceWarmupUtils.default)({})).resolves.not.toThrow();
1228
1281
  case 2:
1229
1282
  case "end":
1230
- return _context31.stop();
1283
+ return _context33.stop();
1231
1284
  }
1232
- }, _callee31);
1285
+ }, _callee33);
1233
1286
  })));
1234
1287
  });
1235
1288
  });