@webex/calling 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.1

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 (259) hide show
  1. package/dist/CallHistory/CallHistory.js +68 -51
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallRecording/CallRecording.js +160 -0
  4. package/dist/CallRecording/CallRecording.js.map +1 -0
  5. package/dist/CallRecording/CallRecording.test.js +257 -0
  6. package/dist/CallRecording/CallRecording.test.js.map +1 -0
  7. package/dist/CallRecording/WxcCallRecordingConnector.js +577 -0
  8. package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
  9. package/dist/CallRecording/WxcCallRecordingConnector.test.js +652 -0
  10. package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
  11. package/dist/CallRecording/callRecordingFixtures.js +235 -0
  12. package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
  13. package/dist/CallRecording/constants.js +50 -0
  14. package/dist/CallRecording/constants.js.map +1 -0
  15. package/dist/CallRecording/types.js +137 -0
  16. package/dist/CallRecording/types.js.map +1 -0
  17. package/dist/CallRecording/utils.js +42 -0
  18. package/dist/CallRecording/utils.js.map +1 -0
  19. package/dist/CallRecording/utils.test.js +97 -0
  20. package/dist/CallRecording/utils.test.js.map +1 -0
  21. package/dist/CallingClient/CallingClient.js +520 -193
  22. package/dist/CallingClient/CallingClient.js.map +1 -1
  23. package/dist/CallingClient/CallingClient.test.js +607 -133
  24. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  25. package/dist/CallingClient/calling/call.js +599 -454
  26. package/dist/CallingClient/calling/call.js.map +1 -1
  27. package/dist/CallingClient/calling/call.test.js +834 -443
  28. package/dist/CallingClient/calling/call.test.js.map +1 -1
  29. package/dist/CallingClient/calling/callManager.js +88 -31
  30. package/dist/CallingClient/calling/callManager.js.map +1 -1
  31. package/dist/CallingClient/calling/callManager.test.js +123 -0
  32. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  33. package/dist/CallingClient/calling/types.js +2 -0
  34. package/dist/CallingClient/calling/types.js.map +1 -1
  35. package/dist/CallingClient/constants.js +30 -3
  36. package/dist/CallingClient/constants.js.map +1 -1
  37. package/dist/CallingClient/line/index.js +4 -1
  38. package/dist/CallingClient/line/index.js.map +1 -1
  39. package/dist/CallingClient/line/line.test.js +16 -1
  40. package/dist/CallingClient/line/line.test.js.map +1 -1
  41. package/dist/CallingClient/registration/register.js +740 -407
  42. package/dist/CallingClient/registration/register.js.map +1 -1
  43. package/dist/CallingClient/registration/register.test.js +380 -58
  44. package/dist/CallingClient/registration/register.test.js.map +1 -1
  45. package/dist/CallingClient/registration/types.js.map +1 -1
  46. package/dist/CallingClient/registration/webWorker.js +41 -104
  47. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  48. package/dist/CallingClient/registration/webWorker.test.js +39 -153
  49. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  50. package/dist/CallingClient/registration/webWorkerStr.js +1 -1
  51. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
  52. package/dist/CallingClient/types.js.map +1 -1
  53. package/dist/CallingClient/utils/constants.js +58 -0
  54. package/dist/CallingClient/utils/constants.js.map +1 -0
  55. package/dist/CallingClient/utils/index.js +63 -0
  56. package/dist/CallingClient/utils/index.js.map +1 -0
  57. package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
  58. package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
  59. package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
  60. package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
  61. package/dist/CallingClient/utils/request.js +435 -0
  62. package/dist/CallingClient/utils/request.js.map +1 -0
  63. package/dist/CallingClient/utils/request.test.js +999 -0
  64. package/dist/CallingClient/utils/request.test.js.map +1 -0
  65. package/dist/CallingClient/utils/types.js +7 -0
  66. package/dist/CallingClient/utils/types.js.map +1 -0
  67. package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
  68. package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
  69. package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
  70. package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
  71. package/dist/Contacts/ContactsClient.js +13 -11
  72. package/dist/Contacts/ContactsClient.js.map +1 -1
  73. package/dist/Contacts/ContactsClient.test.js +3 -8
  74. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  75. package/dist/Events/types.js +38 -11
  76. package/dist/Events/types.js.map +1 -1
  77. package/dist/Metrics/index.js +63 -2
  78. package/dist/Metrics/index.js.map +1 -1
  79. package/dist/Metrics/index.test.js +357 -1
  80. package/dist/Metrics/index.test.js.map +1 -1
  81. package/dist/Metrics/types.js +19 -1
  82. package/dist/Metrics/types.js.map +1 -1
  83. package/dist/SDKConnector/types.js.map +1 -1
  84. package/dist/api.js +56 -0
  85. package/dist/api.js.map +1 -1
  86. package/dist/common/Utils.js +161 -53
  87. package/dist/common/Utils.js.map +1 -1
  88. package/dist/common/Utils.test.js +207 -46
  89. package/dist/common/Utils.test.js.map +1 -1
  90. package/dist/common/testUtil.js +10 -5
  91. package/dist/common/testUtil.js.map +1 -1
  92. package/dist/common/types.js +3 -0
  93. package/dist/common/types.js.map +1 -1
  94. package/dist/index.js +165 -40
  95. package/dist/index.js.map +1 -1
  96. package/dist/mobius-socket/config.js +24 -0
  97. package/dist/mobius-socket/config.js.map +1 -0
  98. package/dist/mobius-socket/errors.js +143 -0
  99. package/dist/mobius-socket/errors.js.map +1 -0
  100. package/dist/mobius-socket/errors.test.js +20 -0
  101. package/dist/mobius-socket/errors.test.js.map +1 -0
  102. package/dist/mobius-socket/index.js +57 -0
  103. package/dist/mobius-socket/index.js.map +1 -0
  104. package/dist/mobius-socket/mobius-socket-events.test.js +492 -0
  105. package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
  106. package/dist/mobius-socket/mobius-socket.js +849 -0
  107. package/dist/mobius-socket/mobius-socket.js.map +1 -0
  108. package/dist/mobius-socket/mobius-socket.test.js +1898 -0
  109. package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
  110. package/dist/mobius-socket/socket/constants.js +55 -0
  111. package/dist/mobius-socket/socket/constants.js.map +1 -0
  112. package/dist/mobius-socket/socket/index.js +15 -0
  113. package/dist/mobius-socket/socket/index.js.map +1 -0
  114. package/dist/mobius-socket/socket/socket-base.js +604 -0
  115. package/dist/mobius-socket/socket/socket-base.js.map +1 -0
  116. package/dist/mobius-socket/socket/socket.js +19 -0
  117. package/dist/mobius-socket/socket/socket.js.map +1 -0
  118. package/dist/mobius-socket/socket/socket.shim.js +26 -0
  119. package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
  120. package/dist/mobius-socket/socket/types.js +7 -0
  121. package/dist/mobius-socket/socket/types.js.map +1 -0
  122. package/dist/mobius-socket/socket.test.js +727 -0
  123. package/dist/mobius-socket/socket.test.js.map +1 -0
  124. package/dist/mobius-socket/test/mocha-helpers.js +23 -0
  125. package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
  126. package/dist/mobius-socket/test/promise-tick.js +28 -0
  127. package/dist/mobius-socket/test/promise-tick.js.map +1 -0
  128. package/dist/mobius-socket/types.js +7 -0
  129. package/dist/mobius-socket/types.js.map +1 -0
  130. package/dist/module/CallHistory/CallHistory.js +28 -17
  131. package/dist/module/CallRecording/CallRecording.js +56 -0
  132. package/dist/module/CallRecording/WxcCallRecordingConnector.js +257 -0
  133. package/dist/module/CallRecording/callRecordingFixtures.js +201 -0
  134. package/dist/module/CallRecording/constants.js +28 -0
  135. package/dist/module/CallRecording/types.js +19 -0
  136. package/dist/module/CallRecording/utils.js +14 -0
  137. package/dist/module/CallingClient/CallingClient.js +166 -8
  138. package/dist/module/CallingClient/calling/call.js +181 -64
  139. package/dist/module/CallingClient/calling/callManager.js +46 -7
  140. package/dist/module/CallingClient/calling/types.js +2 -0
  141. package/dist/module/CallingClient/constants.js +26 -0
  142. package/dist/module/CallingClient/line/index.js +2 -2
  143. package/dist/module/CallingClient/registration/register.js +247 -63
  144. package/dist/module/CallingClient/registration/webWorker.js +42 -61
  145. package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
  146. package/dist/module/CallingClient/utils/constants.js +36 -0
  147. package/dist/module/CallingClient/utils/index.js +5 -0
  148. package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
  149. package/dist/module/CallingClient/utils/request.js +211 -0
  150. package/dist/module/CallingClient/utils/types.js +1 -0
  151. package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
  152. package/dist/module/Contacts/ContactsClient.js +1 -1
  153. package/dist/module/Events/types.js +23 -10
  154. package/dist/module/Metrics/index.js +48 -1
  155. package/dist/module/Metrics/types.js +18 -0
  156. package/dist/module/api.js +3 -2
  157. package/dist/module/common/Utils.js +65 -18
  158. package/dist/module/common/testUtil.js +6 -1
  159. package/dist/module/common/types.js +3 -0
  160. package/dist/module/index.js +7 -3
  161. package/dist/module/mobius-socket/config.js +15 -0
  162. package/dist/module/mobius-socket/errors.js +58 -0
  163. package/dist/module/mobius-socket/index.js +24 -0
  164. package/dist/module/mobius-socket/mobius-socket.js +593 -0
  165. package/dist/module/mobius-socket/socket/constants.js +26 -0
  166. package/dist/module/mobius-socket/socket/index.js +4 -0
  167. package/dist/module/mobius-socket/socket/socket-base.js +368 -0
  168. package/dist/module/mobius-socket/socket/socket.js +9 -0
  169. package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
  170. package/dist/module/mobius-socket/socket/types.js +1 -0
  171. package/dist/module/mobius-socket/types.js +1 -0
  172. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  173. package/dist/types/CallRecording/CallRecording.d.ts +18 -0
  174. package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
  175. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +23 -0
  176. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
  177. package/dist/types/CallRecording/callRecordingFixtures.d.ts +61 -0
  178. package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
  179. package/dist/types/CallRecording/constants.d.ts +29 -0
  180. package/dist/types/CallRecording/constants.d.ts.map +1 -0
  181. package/dist/types/CallRecording/types.d.ts +176 -0
  182. package/dist/types/CallRecording/types.d.ts.map +1 -0
  183. package/dist/types/CallRecording/utils.d.ts +3 -0
  184. package/dist/types/CallRecording/utils.d.ts.map +1 -0
  185. package/dist/types/CallingClient/CallingClient.d.ts +10 -1
  186. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  187. package/dist/types/CallingClient/calling/call.d.ts +12 -0
  188. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  189. package/dist/types/CallingClient/calling/callManager.d.ts +4 -2
  190. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  191. package/dist/types/CallingClient/calling/types.d.ts +34 -9
  192. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  193. package/dist/types/CallingClient/constants.d.ts +26 -0
  194. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  195. package/dist/types/CallingClient/line/index.d.ts +1 -1
  196. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  197. package/dist/types/CallingClient/registration/register.d.ts +9 -2
  198. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  199. package/dist/types/CallingClient/registration/types.d.ts +6 -3
  200. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  201. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
  202. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
  203. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
  204. package/dist/types/CallingClient/types.d.ts +3 -1
  205. package/dist/types/CallingClient/types.d.ts.map +1 -1
  206. package/dist/types/CallingClient/utils/constants.d.ts +35 -0
  207. package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
  208. package/dist/types/CallingClient/utils/index.d.ts +6 -0
  209. package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
  210. package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
  211. package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
  212. package/dist/types/CallingClient/utils/request.d.ts +28 -0
  213. package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
  214. package/dist/types/CallingClient/utils/types.d.ts +34 -0
  215. package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
  216. package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
  217. package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
  218. package/dist/types/Events/types.d.ts +79 -15
  219. package/dist/types/Events/types.d.ts.map +1 -1
  220. package/dist/types/Metrics/index.d.ts.map +1 -1
  221. package/dist/types/Metrics/types.d.ts +19 -2
  222. package/dist/types/Metrics/types.d.ts.map +1 -1
  223. package/dist/types/SDKConnector/types.d.ts +39 -12
  224. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  225. package/dist/types/api.d.ts +6 -4
  226. package/dist/types/api.d.ts.map +1 -1
  227. package/dist/types/common/Utils.d.ts +11 -3
  228. package/dist/types/common/Utils.d.ts.map +1 -1
  229. package/dist/types/common/testUtil.d.ts +5 -1
  230. package/dist/types/common/testUtil.d.ts.map +1 -1
  231. package/dist/types/common/types.d.ts +9 -1
  232. package/dist/types/common/types.d.ts.map +1 -1
  233. package/dist/types/index.d.ts +8 -3
  234. package/dist/types/index.d.ts.map +1 -1
  235. package/dist/types/mobius-socket/config.d.ts +17 -0
  236. package/dist/types/mobius-socket/config.d.ts.map +1 -0
  237. package/dist/types/mobius-socket/errors.d.ts +32 -0
  238. package/dist/types/mobius-socket/errors.d.ts.map +1 -0
  239. package/dist/types/mobius-socket/index.d.ts +14 -0
  240. package/dist/types/mobius-socket/index.d.ts.map +1 -0
  241. package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
  242. package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
  243. package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
  244. package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
  245. package/dist/types/mobius-socket/socket/index.d.ts +5 -0
  246. package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
  247. package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
  248. package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
  249. package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
  250. package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
  251. package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
  252. package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
  253. package/dist/types/mobius-socket/socket/types.d.ts +61 -0
  254. package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
  255. package/dist/types/mobius-socket/types.d.ts +21 -0
  256. package/dist/types/mobius-socket/types.d.ts.map +1 -0
  257. package/package.json +20 -5
  258. package/src/mobius-socket/socket/socket.shim.ts +22 -0
  259. package/src/mobius-socket/socket/socket.ts +14 -0
@@ -8,10 +8,12 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
9
9
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
10
10
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
11
+ var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
11
12
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
13
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
12
14
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
13
15
  var InternalMediaCoreModule = _interopRequireWildcard(require("@webex/internal-media-core"));
14
- var _webMediaEffects = require("@webex/web-media-effects");
16
+ var _mediaHelpers = require("@webex/media-helpers");
15
17
  var _types = require("../../Errors/types");
16
18
  var _Utils = _interopRequireWildcard(require("../../common/Utils"));
17
19
  var Utils = _Utils;
@@ -26,11 +28,19 @@ var _callManager = require("./callManager");
26
28
  var _Logger = _interopRequireDefault(require("../../Logger"));
27
29
  var _Errors = require("../../Errors");
28
30
  var _constants2 = require("../../common/constants");
31
+ var _request = require("../utils/request");
29
32
  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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
30
33
  /* eslint-disable @typescript-eslint/no-explicit-any */
31
34
  /* eslint-disable dot-notation */
32
35
  /* eslint-disable @typescript-eslint/no-shadow */
33
36
 
37
+ jest.mock('../../mobius-socket', function () {
38
+ return {
39
+ getMobiusSocketInstance: jest.fn().mockReturnValue({
40
+ sendWssRequest: jest.fn()
41
+ })
42
+ };
43
+ });
34
44
  jest.mock('@webex/internal-media-core');
35
45
  var uploadLogsSpy = jest.spyOn(Utils, 'uploadLogs').mockResolvedValue(undefined);
36
46
  var webex = (0, _testUtil.getTestUtilsWebex)();
@@ -115,6 +125,11 @@ describe('Call Tests', function () {
115
125
  webex.request = jest.fn();
116
126
  });
117
127
  beforeEach(function () {
128
+ _request.APIRequest.resetInstance();
129
+ _request.APIRequest.getInstance({
130
+ webex: webex,
131
+ isMobiusSocketEnabled: false
132
+ });
118
133
  callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
119
134
  });
120
135
  it('create call object', function () {
@@ -427,10 +442,218 @@ describe('Call Tests', function () {
427
442
  }
428
443
  }, _callee8);
429
444
  })));
430
- it('testing enabling/disabling the BNR on an active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
431
- var mockStream, localAudioStream, onStreamSpy, onEffectSpy, offStreamSpy, offEffectSpy, call, updateLocalTracksSpy, bnrMetricSpy;
445
+ it('registers and unregisters media connection listeners with stable handlers', function () {
446
+ var mockStream = {
447
+ outputStream: {
448
+ getAudioTracks: jest.fn().mockReturnValue([mockTrack])
449
+ },
450
+ on: jest.fn(),
451
+ getEffectByKind: jest.fn().mockReturnValue(undefined)
452
+ };
453
+ var localAudioStream = mockStream;
454
+ var call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
455
+ call.dial(localAudioStream);
456
+ var mediaOnMock = call['mediaConnection'].on;
457
+ var mediaOffSpy = jest.spyOn(call['mediaConnection'], 'off');
458
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ROAP_MESSAGE_TO_SEND, expect.any(Function));
459
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ROAP_FAILURE, expect.any(Function));
460
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.REMOTE_TRACK_ADDED, expect.any(Function));
461
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED, expect.any(Function));
462
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED, expect.any(Function));
463
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED, expect.any(Function));
464
+ expect(mediaOnMock).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CANDIDATE_ERROR, expect.any(Function));
465
+ call['unregisterMediaConnectionListeners']();
466
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ROAP_MESSAGE_TO_SEND, expect.any(Function));
467
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ROAP_FAILURE, expect.any(Function));
468
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.REMOTE_TRACK_ADDED, expect.any(Function));
469
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED, expect.any(Function));
470
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED, expect.any(Function));
471
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED, expect.any(Function));
472
+ expect(mediaOffSpy).toBeCalledWith(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CANDIDATE_ERROR, expect.any(Function));
473
+ });
474
+ it('handles ICE listener payloads and submits metrics with event names', function () {
475
+ var mockStream = {
476
+ outputStream: {
477
+ getAudioTracks: jest.fn().mockReturnValue([mockTrack])
478
+ },
479
+ on: jest.fn(),
480
+ getEffectByKind: jest.fn().mockReturnValue(undefined)
481
+ };
482
+ var localAudioStream = mockStream;
483
+ var call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
484
+ call.dial(localAudioStream);
485
+ var metricSpy = jest.spyOn(call['metricManager'], 'submitMediaMetric');
486
+ var warnSpy = jest.spyOn(_Logger.default, 'warn');
487
+ var getHandlerForEvent = function getHandlerForEvent(eventName) {
488
+ var _mock$calls$find;
489
+ return (_mock$calls$find = call['mediaConnection'].on.mock.calls.find(function (_ref9) {
490
+ var _ref0 = (0, _slicedToArray2.default)(_ref9, 1),
491
+ name = _ref0[0];
492
+ return name === eventName;
493
+ })) === null || _mock$calls$find === void 0 ? void 0 : _mock$calls$find[1];
494
+ };
495
+ var iceGatheringHandler = getHandlerForEvent(InternalMediaCoreModule.MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED);
496
+ var peerConnectionHandler = getHandlerForEvent(InternalMediaCoreModule.MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED);
497
+ var iceConnectionHandler = getHandlerForEvent(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
498
+ var iceCandidateErrorHandler = getHandlerForEvent(InternalMediaCoreModule.MediaConnectionEventNames.ICE_CANDIDATE_ERROR);
499
+ iceGatheringHandler({
500
+ iceGatheringState: 'gathering'
501
+ });
502
+ peerConnectionHandler({
503
+ connectionState: 'connected'
504
+ });
505
+ iceConnectionHandler({
506
+ iceConnectionState: 'completed'
507
+ });
508
+ iceCandidateErrorHandler({
509
+ errorCode: 701,
510
+ errorText: 'STUN host lookup failed',
511
+ url: 'stun:example.org:3478'
512
+ });
513
+ expect(metricSpy).toHaveBeenNthCalledWith(1, _types4.METRIC_EVENT.MEDIA, _types4.MEDIA_CONNECTION_ACTION.ICE_GATHERING_STATE_CHANGED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined, undefined, 'gathering');
514
+ expect(metricSpy).toHaveBeenNthCalledWith(2, _types4.METRIC_EVENT.MEDIA, _types4.MEDIA_CONNECTION_ACTION.PEER_CONNECTION_STATE_CHANGED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined, undefined, 'connected');
515
+ expect(metricSpy).toHaveBeenNthCalledWith(3, _types4.METRIC_EVENT.MEDIA, _types4.MEDIA_CONNECTION_ACTION.ICE_CONNECTION_STATE_CHANGED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined, undefined, 'completed');
516
+ expect(metricSpy).toHaveBeenNthCalledWith(4, _types4.METRIC_EVENT.MEDIA_ERROR, _types4.MEDIA_CONNECTION_ACTION.ICE_CANDIDATE_ERROR, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined, undefined, undefined, expect.any(_Errors.CallError));
517
+ var mediaErrorCall = metricSpy.mock.calls[3];
518
+ expect(mediaErrorCall[mediaErrorCall.length - 1].getCallError().message).toBe('ICE candidate error occurred: {"address":null,"errorCode":701,"errorText":"STUN host lookup failed","port":null,"url":"stun:example.org:3478"}');
519
+ expect(warnSpy).toHaveBeenCalledWith('ICE candidate error occurred: {"address":null,"errorCode":701,"errorText":"STUN host lookup failed","port":null,"url":"stun:example.org:3478"}', {
520
+ file: 'call',
521
+ method: 'mediaIceEventsListener'
522
+ });
523
+ });
524
+ it('handles ROAP failure listener and submits media error metric', function () {
525
+ var _mock$calls$find2;
526
+ var mockStream = {
527
+ outputStream: {
528
+ getAudioTracks: jest.fn().mockReturnValue([mockTrack])
529
+ },
530
+ on: jest.fn(),
531
+ getEffectByKind: jest.fn().mockReturnValue(undefined)
532
+ };
533
+ var localAudioStream = mockStream;
534
+ var call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
535
+ call.dial(localAudioStream);
536
+ var metricSpy = jest.spyOn(call['metricManager'], 'submitMediaMetric');
537
+ var warnSpy = jest.spyOn(_Logger.default, 'warn');
538
+ var roapFailureHandler = (_mock$calls$find2 = call['mediaConnection'].on.mock.calls.find(function (_ref1) {
539
+ var _ref10 = (0, _slicedToArray2.default)(_ref1, 1),
540
+ name = _ref10[0];
541
+ return name === InternalMediaCoreModule.MediaConnectionEventNames.ROAP_FAILURE;
542
+ })) === null || _mock$calls$find2 === void 0 ? void 0 : _mock$calls$find2[1];
543
+ var roapFailure = new Error('Failed to process remote SDP');
544
+ roapFailureHandler(roapFailure);
545
+ expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.MEDIA_ERROR, _types4.MEDIA_CONNECTION_ACTION.ROAP_FAILURE, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), undefined, undefined, undefined, expect.any(_Errors.CallError));
546
+ var roapFailureMetricCall = metricSpy.mock.calls.find(function (_ref11) {
547
+ var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
548
+ name = _ref12[0],
549
+ metricAction = _ref12[1];
550
+ return name === _types4.METRIC_EVENT.MEDIA_ERROR && metricAction === _types4.MEDIA_CONNECTION_ACTION.ROAP_FAILURE;
551
+ });
552
+ expect(roapFailureMetricCall).toBeDefined();
553
+ expect((roapFailureMetricCall === null || roapFailureMetricCall === void 0 ? void 0 : roapFailureMetricCall[roapFailureMetricCall.length - 1]).getCallError().message).toBe('ROAP failure occurred: Failed to process remote SDP');
554
+ expect(warnSpy).toHaveBeenCalledWith('ROAP failure occurred: Failed to process remote SDP', {
555
+ file: 'call',
556
+ method: 'mediaRoapEventsListener'
557
+ });
558
+ });
559
+ it('sends connect before ROAP answer when inbound offer is delayed', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
560
+ var _mock$calls$find3;
561
+ var mockStream, localAudioStream, call, handleOutgoingCallConnectSpy, delayedOffer, sendCallStateMachineEvtSpy, sendMediaStateMachineEvtSpy, roapListener;
432
562
  return _regenerator.default.wrap(function (_context9) {
433
563
  while (1) switch (_context9.prev = _context9.next) {
564
+ case 0:
565
+ mockStream = {
566
+ outputStream: {
567
+ getAudioTracks: jest.fn().mockReturnValue([mockTrack])
568
+ },
569
+ on: jest.fn(),
570
+ getEffectByKind: jest.fn().mockImplementation(function () {
571
+ return mockEffect;
572
+ })
573
+ };
574
+ localAudioStream = mockStream;
575
+ call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.INBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
576
+ webex.request.mockReturnValue({
577
+ statusCode: 200,
578
+ body: {
579
+ callId: 'mock-call-id'
580
+ }
581
+ });
582
+ call.sendCallStateMachineEvt({
583
+ type: 'E_RECV_CALL_SETUP',
584
+ data: {
585
+ seq: 1,
586
+ messageType: 'OFFER'
587
+ }
588
+ });
589
+ expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
590
+ _context9.next = 1;
591
+ return call.answer(localAudioStream);
592
+ case 1:
593
+ expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
594
+
595
+ // Connect is attempted by answer(), but is deferred because offer is not buffered yet.
596
+ handleOutgoingCallConnectSpy = jest.spyOn(call, 'handleOutgoingCallConnect');
597
+ expect(call['connectPending']).toBe(true);
598
+ expect(call['mediaConnection'].roapMessageReceived).not.toHaveBeenCalled();
599
+ delayedOffer = {
600
+ seq: 1,
601
+ messageType: 'OFFER',
602
+ sdp: 'v=0',
603
+ version: 1
604
+ };
605
+ call.sendMediaStateMachineEvt({
606
+ type: 'E_RECV_ROAP_OFFER',
607
+ data: delayedOffer
608
+ });
609
+ _context9.next = 2;
610
+ return (0, _testUtil.flushPromises)(2);
611
+ case 2:
612
+ expect(call['mediaConnection'].roapMessageReceived).toHaveBeenCalledWith(delayedOffer);
613
+ sendCallStateMachineEvtSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
614
+ sendMediaStateMachineEvtSpy = jest.spyOn(call, 'sendMediaStateMachineEvt');
615
+ roapListener = (_mock$calls$find3 = call['mediaConnection'].on.mock.calls.find(function (_ref14) {
616
+ var _ref15 = (0, _slicedToArray2.default)(_ref14, 1),
617
+ eventName = _ref15[0];
618
+ return eventName === InternalMediaCoreModule.MediaConnectionEventNames.ROAP_MESSAGE_TO_SEND;
619
+ })) === null || _mock$calls$find3 === void 0 ? void 0 : _mock$calls$find3[1];
620
+ expect(roapListener).toBeDefined();
621
+ _context9.next = 3;
622
+ return roapListener({
623
+ roapMessage: {
624
+ messageType: 'ANSWER',
625
+ sdp: 'v=0',
626
+ seq: 1,
627
+ version: 2
628
+ }
629
+ });
630
+ case 3:
631
+ _context9.next = 4;
632
+ return (0, _testUtil.flushPromises)(2);
633
+ case 4:
634
+ // On ANSWER from media layer, connect is retried first, then ROAP answer is posted.
635
+ expect(sendCallStateMachineEvtSpy).toHaveBeenNthCalledWith(1, {
636
+ type: 'E_SEND_CALL_CONNECT'
637
+ });
638
+ expect(sendMediaStateMachineEvtSpy).toHaveBeenNthCalledWith(1, {
639
+ type: 'E_SEND_ROAP_ANSWER',
640
+ data: expect.objectContaining({
641
+ messageType: 'ANSWER'
642
+ })
643
+ });
644
+ expect(handleOutgoingCallConnectSpy).toHaveBeenCalled();
645
+ expect(call['mediaConnection'].roapMessageReceived).toHaveBeenLastCalledWith(delayedOffer);
646
+ expect(call['connectPending']).toBe(false);
647
+ case 5:
648
+ case "end":
649
+ return _context9.stop();
650
+ }
651
+ }, _callee9);
652
+ })));
653
+ it('testing enabling/disabling the BNR on an active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
654
+ var mockStream, localAudioStream, onStreamSpy, onEffectSpy, offStreamSpy, offEffectSpy, call, updateLocalTracksSpy, bnrMetricSpy;
655
+ return _regenerator.default.wrap(function (_context0) {
656
+ while (1) switch (_context0.prev = _context0.next) {
434
657
  case 0:
435
658
  mockStream = {
436
659
  outputStream: {
@@ -462,8 +685,8 @@ describe('Call Tests', function () {
462
685
  bnrMetricSpy.mockClear();
463
686
  /* Invoking the callback function to trigger EffectAdded event to simulate adding effect to the stream */
464
687
  onStreamSpy.mock.calls[1][1](mockEffect);
465
- expect(onEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Enabled, expect.any(Function));
466
- expect(onEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Disabled, expect.any(Function));
688
+ expect(onEffectSpy).toBeCalledWith(_mediaHelpers.EffectEvent.Enabled, expect.any(Function));
689
+ expect(onEffectSpy).toBeCalledWith(_mediaHelpers.EffectEvent.Disabled, expect.any(Function));
467
690
 
468
691
  /* Send Enabled event on the effect, update track and send metrics for BNR disabled */
469
692
  onStreamSpy.mock.calls[0][1](mockTrack);
@@ -486,25 +709,25 @@ describe('Call Tests', function () {
486
709
  });
487
710
  expect(bnrMetricSpy).toBeCalledOnceWith(_types4.METRIC_EVENT.BNR_DISABLED, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId());
488
711
  call.end();
489
- _context9.next = 1;
712
+ _context0.next = 1;
490
713
  return (0, _Utils.waitForMsecs)(50);
491
714
  case 1:
492
715
  /* Checks for switching off the listeners on call disconnect */
493
716
  expect(offStreamSpy).toBeCalledTimes(2);
494
717
  expect(offStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.OutputTrackChange, expect.any(Function));
495
718
  expect(offStreamSpy).toBeCalledWith(InternalMediaCoreModule.LocalStreamEventNames.EffectAdded, expect.any(Function));
496
- expect(offEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Enabled, expect.any(Function));
497
- expect(offEffectSpy).toBeCalledWith(_webMediaEffects.EffectEvent.Disabled, expect.any(Function));
719
+ expect(offEffectSpy).toBeCalledWith(_mediaHelpers.EffectEvent.Enabled, expect.any(Function));
720
+ expect(offEffectSpy).toBeCalledWith(_mediaHelpers.EffectEvent.Disabled, expect.any(Function));
498
721
  case 2:
499
722
  case "end":
500
- return _context9.stop();
723
+ return _context0.stop();
501
724
  }
502
- }, _callee9);
725
+ }, _callee0);
503
726
  })));
504
- it('answer fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
727
+ it('answer fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
505
728
  var mockStream, localAudioStream, warnSpy, call;
506
- return _regenerator.default.wrap(function (_context0) {
507
- while (1) switch (_context0.prev = _context0.next) {
729
+ return _regenerator.default.wrap(function (_context1) {
730
+ while (1) switch (_context1.prev = _context1.next) {
508
731
  case 0:
509
732
  mockStream = {
510
733
  outputStream: {
@@ -528,7 +751,7 @@ describe('Call Tests', function () {
528
751
  warnSpy = jest.spyOn(_Logger.default, 'warn');
529
752
  call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
530
753
  call.answer(localAudioStream);
531
- _context0.next = 1;
754
+ _context1.next = 1;
532
755
  return (0, _Utils.waitForMsecs)(50);
533
756
  case 1:
534
757
  expect(warnSpy).toBeCalledTimes(2);
@@ -543,14 +766,14 @@ describe('Call Tests', function () {
543
766
  expect(webex.request.mock.calls[0][0].body.metrics).toStrictEqual(disconnectStats);
544
767
  case 2:
545
768
  case "end":
546
- return _context0.stop();
769
+ return _context1.stop();
547
770
  }
548
- }, _callee0);
771
+ }, _callee1);
549
772
  })));
550
- it('dial fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
773
+ it('dial fails if localAudioTrack is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
551
774
  var mockStream, localAudioStream, warnSpy, call;
552
- return _regenerator.default.wrap(function (_context1) {
553
- while (1) switch (_context1.prev = _context1.next) {
775
+ return _regenerator.default.wrap(function (_context10) {
776
+ while (1) switch (_context10.prev = _context10.next) {
554
777
  case 0:
555
778
  mockStream = {
556
779
  outputStream: {
@@ -562,7 +785,7 @@ describe('Call Tests', function () {
562
785
  warnSpy = jest.spyOn(_Logger.default, 'warn');
563
786
  call = (0, _call.createCall)(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, deleteCallFromCollection, defaultServiceIndicator, dest);
564
787
  call.dial(localAudioStream);
565
- _context1.next = 1;
788
+ _context10.next = 1;
566
789
  return (0, _Utils.waitForMsecs)(50);
567
790
  case 1:
568
791
  expect(warnSpy).toBeCalledTimes(1);
@@ -575,9 +798,9 @@ describe('Call Tests', function () {
575
798
  expect(webex.request).not.toBeCalledOnceWith();
576
799
  case 2:
577
800
  case "end":
578
- return _context1.stop();
801
+ return _context10.stop();
579
802
  }
580
- }, _callee1);
803
+ }, _callee10);
581
804
  })));
582
805
  it('update media after call creation with valid stream', function () {
583
806
  var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
@@ -651,10 +874,10 @@ describe('Call Tests', function () {
651
874
  method: 'dial'
652
875
  });
653
876
  });
654
- it('test system mute and user mute different scnearios', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
877
+ it('test system mute and user mute different scnearios', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
655
878
  var logSpy, callManager, mockStream, localAudioStream, call;
656
- return _regenerator.default.wrap(function (_context10) {
657
- while (1) switch (_context10.prev = _context10.next) {
879
+ return _regenerator.default.wrap(function (_context11) {
880
+ while (1) switch (_context11.prev = _context11.next) {
658
881
  case 0:
659
882
  logSpy = jest.spyOn(_Logger.default, 'info');
660
883
  webex.request.mockReturnValue({
@@ -730,9 +953,9 @@ describe('Call Tests', function () {
730
953
  expect(mockStream.setUserMuted).toBeCalledOnceWith(false);
731
954
  case 1:
732
955
  case "end":
733
- return _context10.stop();
956
+ return _context11.stop();
734
957
  }
735
- }, _callee10);
958
+ }, _callee11);
736
959
  })));
737
960
  describe('Guest Calling Flow Tests', function () {
738
961
  var dummyEvent = {
@@ -740,10 +963,10 @@ describe('Call Tests', function () {
740
963
  data: undefined
741
964
  };
742
965
  var call;
743
- it('outgoing call without guest calling must have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
966
+ it('outgoing call without guest calling must have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
744
967
  var requestSpy, requestArgs;
745
- return _regenerator.default.wrap(function (_context11) {
746
- while (1) switch (_context11.prev = _context11.next) {
968
+ return _regenerator.default.wrap(function (_context12) {
969
+ while (1) switch (_context12.prev = _context12.next) {
747
970
  case 0:
748
971
  call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
749
972
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -756,14 +979,14 @@ describe('Call Tests', function () {
756
979
  expect('callee' in requestArgs.body).toBe(true);
757
980
  case 1:
758
981
  case "end":
759
- return _context11.stop();
982
+ return _context12.stop();
760
983
  }
761
- }, _callee11);
984
+ }, _callee12);
762
985
  })));
763
- it('outgoing call for guest calling must not have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
986
+ it('outgoing call for guest calling must not have callee', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
764
987
  var requestSpy, requestArgs;
765
- return _regenerator.default.wrap(function (_context12) {
766
- while (1) switch (_context12.prev = _context12.next) {
988
+ return _regenerator.default.wrap(function (_context13) {
989
+ while (1) switch (_context13.prev = _context13.next) {
767
990
  case 0:
768
991
  call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
769
992
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -776,9 +999,9 @@ describe('Call Tests', function () {
776
999
  expect('callee' in requestArgs.body).toBe(false);
777
1000
  case 1:
778
1001
  case "end":
779
- return _context12.stop();
1002
+ return _context13.stop();
780
1003
  }
781
- }, _callee12);
1004
+ }, _callee13);
782
1005
  })));
783
1006
  });
784
1007
  });
@@ -798,6 +1021,11 @@ describe('State Machine handler tests', function () {
798
1021
  var call;
799
1022
  var dtmfMock;
800
1023
  beforeEach(function () {
1024
+ _request.APIRequest.resetInstance();
1025
+ _request.APIRequest.getInstance({
1026
+ webex: webex,
1027
+ isMobiusSocketEnabled: false
1028
+ });
801
1029
  call = new _call.Call(activeUrl, webex, _types3.CallDirection.OUTBOUND, deviceId, mockLineId, function () {
802
1030
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
803
1031
  var dummy = 10;
@@ -811,10 +1039,10 @@ describe('State Machine handler tests', function () {
811
1039
 
812
1040
  // afterEach(() => call.removeAllListeners());
813
1041
 
814
- it('successful session refresh', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1042
+ it('successful session refresh', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
815
1043
  var statusPayload, dummyEvent, funcSpy, logSpy;
816
- return _regenerator.default.wrap(function (_context13) {
817
- while (1) switch (_context13.prev = _context13.next) {
1044
+ return _regenerator.default.wrap(function (_context14) {
1045
+ while (1) switch (_context14.prev = _context14.next) {
818
1046
  case 0:
819
1047
  statusPayload = {
820
1048
  statusCode: 200,
@@ -834,7 +1062,7 @@ describe('State Machine handler tests', function () {
834
1062
  /* This is to flush all the promises from the Promise queue so that
835
1063
  * Jest.fakeTimers can advance time and also clear the promise Queue
836
1064
  */
837
- _context13.next = 1;
1065
+ _context14.next = 1;
838
1066
  return (0, _testUtil.flushPromises)(3);
839
1067
  case 1:
840
1068
  expect(setInterval).toHaveBeenCalledTimes(1);
@@ -850,14 +1078,14 @@ describe('State Machine handler tests', function () {
850
1078
  });
851
1079
  case 2:
852
1080
  case "end":
853
- return _context13.stop();
1081
+ return _context14.stop();
854
1082
  }
855
- }, _callee13);
1083
+ }, _callee14);
856
1084
  })));
857
- it('session refresh 401 emits token error and ends the call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1085
+ it('session refresh 401 emits token error and ends the call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
858
1086
  var statusPayload, emitSpy, funcSpy;
859
- return _regenerator.default.wrap(function (_context14) {
860
- while (1) switch (_context14.prev = _context14.next) {
1087
+ return _regenerator.default.wrap(function (_context15) {
1088
+ while (1) switch (_context15.prev = _context15.next) {
861
1089
  case 0:
862
1090
  expect.assertions(4);
863
1091
  statusPayload = {
@@ -872,25 +1100,27 @@ describe('State Machine handler tests', function () {
872
1100
  funcSpy = jest.spyOn(call, 'postStatus').mockRejectedValue(statusPayload);
873
1101
  call['handleCallEstablished']({});
874
1102
  jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
875
- _context14.next = 1;
1103
+ _context15.next = 1;
876
1104
  return _promise.default.resolve();
877
1105
  case 1:
878
- _context14.next = 2;
1106
+ _context15.next = 2;
879
1107
  return _promise.default.resolve();
880
1108
  case 2:
881
- expect(clearInterval).toHaveBeenCalledTimes(1);
1109
+ // clearInterval is called twice: once in scheduleCallKeepaliveInterval (at start)
1110
+ // and once in handleCallKeepaliveError when clearing timer due to error
1111
+ expect(clearInterval).toHaveBeenCalledTimes(2);
882
1112
  expect(funcSpy).toBeCalledTimes(1);
883
1113
  expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
884
1114
  case 3:
885
1115
  case "end":
886
- return _context14.stop();
1116
+ return _context15.stop();
887
1117
  }
888
- }, _callee14);
1118
+ }, _callee15);
889
1119
  })));
890
- it('session refresh failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1120
+ it('session refresh failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
891
1121
  var statusPayload, funcSpy;
892
- return _regenerator.default.wrap(function (_context15) {
893
- while (1) switch (_context15.prev = _context15.next) {
1122
+ return _regenerator.default.wrap(function (_context16) {
1123
+ while (1) switch (_context16.prev = _context16.next) {
894
1124
  case 0:
895
1125
  expect.assertions(4);
896
1126
  statusPayload = {
@@ -909,21 +1139,23 @@ describe('State Machine handler tests', function () {
909
1139
  /* This is to flush all the promises from the Promise queue so that
910
1140
  * Jest.fakeTimers can advance time and also clear the promise Queue
911
1141
  */
912
- _context15.next = 1;
1142
+ _context16.next = 1;
913
1143
  return (0, _testUtil.flushPromises)(2);
914
1144
  case 1:
915
- expect(clearInterval).toHaveBeenCalledTimes(1);
1145
+ // clearInterval is called twice: once in scheduleCallKeepaliveInterval (at start)
1146
+ // and once in handleCallKeepaliveError when clearing timer due to error
1147
+ expect(clearInterval).toHaveBeenCalledTimes(2);
916
1148
  expect(funcSpy).toBeCalledTimes(1);
917
1149
  case 2:
918
1150
  case "end":
919
- return _context15.stop();
1151
+ return _context16.stop();
920
1152
  }
921
- }, _callee15);
1153
+ }, _callee16);
922
1154
  })));
923
- it('session refresh 500 schedules retry via retry-after or default interval', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1155
+ it('session refresh 500 schedules retry via retry-after or default interval', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
924
1156
  var errorPayload, okPayload, scheduleKeepaliveSpy, postStatusSpy;
925
- return _regenerator.default.wrap(function (_context16) {
926
- while (1) switch (_context16.prev = _context16.next) {
1157
+ return _regenerator.default.wrap(function (_context17) {
1158
+ while (1) switch (_context17.prev = _context17.next) {
927
1159
  case 0:
928
1160
  errorPayload = {
929
1161
  statusCode: 500,
@@ -941,28 +1173,63 @@ describe('State Machine handler tests', function () {
941
1173
  call['handleCallEstablished']({});
942
1174
  }
943
1175
  jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
944
- _context16.next = 1;
1176
+ _context17.next = 1;
945
1177
  return (0, _testUtil.flushPromises)(2);
946
1178
  case 1:
947
1179
  expect(postStatusSpy).toHaveBeenCalledTimes(1);
948
1180
 
949
1181
  // Now advance by 1 second for the retry-after interval
950
1182
  jest.advanceTimersByTime(1000);
951
- _context16.next = 2;
1183
+ _context17.next = 2;
952
1184
  return (0, _testUtil.flushPromises)(2);
953
1185
  case 2:
954
1186
  expect(postStatusSpy).toHaveBeenCalledTimes(2);
955
1187
  expect(scheduleKeepaliveSpy).toHaveBeenCalledTimes(2);
956
1188
  case 3:
957
1189
  case "end":
958
- return _context16.stop();
1190
+ return _context17.stop();
959
1191
  }
960
- }, _callee16);
1192
+ }, _callee17);
961
1193
  })));
962
- it('keepalive ends after reaching max retry count', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1194
+ it('scheduleCallKeepaliveInterval clears existing interval before creating new one', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1195
+ var firstTimer, secondTimer;
1196
+ return _regenerator.default.wrap(function (_context18) {
1197
+ while (1) switch (_context18.prev = _context18.next) {
1198
+ case 0:
1199
+ jest.spyOn(global, 'setInterval');
1200
+ jest.spyOn(global, 'clearInterval');
1201
+
1202
+ // Setup the first keepalive interval
1203
+ call['handleCallEstablished']({});
1204
+
1205
+ // At this point, scheduleCallKeepaliveInterval was called once
1206
+ // It should have called clearInterval once (at the start) and setInterval once
1207
+ expect(clearInterval).toHaveBeenCalledTimes(1);
1208
+ expect(setInterval).toHaveBeenCalledTimes(1);
1209
+ firstTimer = call['sessionTimer'];
1210
+ expect(firstTimer).toBeDefined();
1211
+
1212
+ // Manually call scheduleCallKeepaliveInterval again to simulate a retry scenario
1213
+ call['scheduleCallKeepaliveInterval']();
1214
+
1215
+ // clearInterval should have been called again to clear the previous timer
1216
+ expect(clearInterval).toHaveBeenCalledTimes(2);
1217
+ // A new interval should have been created
1218
+ expect(setInterval).toHaveBeenCalledTimes(2);
1219
+
1220
+ // The sessionTimer should be different (new timer)
1221
+ secondTimer = call['sessionTimer'];
1222
+ expect(secondTimer).toBeDefined();
1223
+ case 1:
1224
+ case "end":
1225
+ return _context18.stop();
1226
+ }
1227
+ }, _callee18);
1228
+ })));
1229
+ it('keepalive ends after reaching max retry count', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
963
1230
  var errorPayload, warnSpy, postStatusSpy;
964
- return _regenerator.default.wrap(function (_context17) {
965
- while (1) switch (_context17.prev = _context17.next) {
1231
+ return _regenerator.default.wrap(function (_context19) {
1232
+ while (1) switch (_context19.prev = _context19.next) {
966
1233
  case 0:
967
1234
  errorPayload = {
968
1235
  statusCode: 500,
@@ -981,25 +1248,25 @@ describe('State Machine handler tests', function () {
981
1248
 
982
1249
  // Advance timer to trigger the first failure (uses DEFAULT_SESSION_TIMER)
983
1250
  jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
984
- _context17.next = 1;
1251
+ _context19.next = 1;
985
1252
  return (0, _testUtil.flushPromises)(2);
986
1253
  case 1:
987
1254
  // Now advance by 1 second for each of the 4 retry attempts (retry-after: 1 second each)
988
1255
  // Need to do this separately to allow state machine to process and create new intervals
989
1256
  jest.advanceTimersByTime(1000);
990
- _context17.next = 2;
1257
+ _context19.next = 2;
991
1258
  return (0, _testUtil.flushPromises)(2);
992
1259
  case 2:
993
1260
  jest.advanceTimersByTime(1000);
994
- _context17.next = 3;
1261
+ _context19.next = 3;
995
1262
  return (0, _testUtil.flushPromises)(2);
996
1263
  case 3:
997
1264
  jest.advanceTimersByTime(1000);
998
- _context17.next = 4;
1265
+ _context19.next = 4;
999
1266
  return (0, _testUtil.flushPromises)(2);
1000
1267
  case 4:
1001
1268
  jest.advanceTimersByTime(1000);
1002
- _context17.next = 5;
1269
+ _context19.next = 5;
1003
1270
  return (0, _testUtil.flushPromises)(2);
1004
1271
  case 5:
1005
1272
  // The error handler should detect we're at max retry count and stop
@@ -1011,14 +1278,14 @@ describe('State Machine handler tests', function () {
1011
1278
  expect(call['callKeepaliveRetryCount']).toBe(4);
1012
1279
  case 6:
1013
1280
  case "end":
1014
- return _context17.stop();
1281
+ return _context19.stop();
1015
1282
  }
1016
- }, _callee17);
1283
+ }, _callee19);
1017
1284
  })));
1018
- it('state changes during successful incoming call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1285
+ it('state changes during successful incoming call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1019
1286
  var statusPayload, dummyEvent, postMediaSpy, deleteSpy, dummyOkEvent;
1020
- return _regenerator.default.wrap(function (_context18) {
1021
- while (1) switch (_context18.prev = _context18.next) {
1287
+ return _regenerator.default.wrap(function (_context20) {
1288
+ while (1) switch (_context20.prev = _context20.next) {
1022
1289
  case 0:
1023
1290
  statusPayload = {
1024
1291
  statusCode: 200,
@@ -1074,14 +1341,14 @@ describe('State Machine handler tests', function () {
1074
1341
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
1075
1342
  case 1:
1076
1343
  case "end":
1077
- return _context18.stop();
1344
+ return _context20.stop();
1078
1345
  }
1079
- }, _callee18);
1346
+ }, _callee20);
1080
1347
  })));
1081
- it('state changes during unsuccessful incoming call due to no offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1348
+ it('state changes during unsuccessful incoming call due to no offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1082
1349
  var statusPayload, dummyEvent;
1083
- return _regenerator.default.wrap(function (_context19) {
1084
- while (1) switch (_context19.prev = _context19.next) {
1350
+ return _regenerator.default.wrap(function (_context21) {
1351
+ while (1) switch (_context21.prev = _context21.next) {
1085
1352
  case 0:
1086
1353
  call['direction'] = _types3.CallDirection.INBOUND;
1087
1354
  statusPayload = {
@@ -1099,7 +1366,7 @@ describe('State Machine handler tests', function () {
1099
1366
  webex.request.mockReturnValue(statusPayload);
1100
1367
  call.sendCallStateMachineEvt(dummyEvent);
1101
1368
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
1102
- _context19.next = 1;
1369
+ _context21.next = 1;
1103
1370
  return call['handleOutgoingCallConnect']({
1104
1371
  type: 'E_SEND_CALL_CONNECT'
1105
1372
  });
@@ -1113,14 +1380,115 @@ describe('State Machine handler tests', function () {
1113
1380
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
1114
1381
  case 2:
1115
1382
  case "end":
1116
- return _context19.stop();
1383
+ return _context21.stop();
1117
1384
  }
1118
- }, _callee19);
1385
+ }, _callee21);
1119
1386
  })));
1120
- it('state changes during unsuccessful incoming call due error in call connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1387
+ it('processes callerId on received progress event in established state without emitting PROGRESS', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1388
+ var callManager, statusPayload, call, dummyEvent, dummyOkEvent, emitSpy, startCallerIdSpy, mobiusProgressEvent;
1389
+ return _regenerator.default.wrap(function (_context22) {
1390
+ while (1) switch (_context22.prev = _context22.next) {
1391
+ case 0:
1392
+ callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
1393
+ statusPayload = {
1394
+ statusCode: 200,
1395
+ body: mockStatusBody
1396
+ };
1397
+ call = callManager.createCall(_types3.CallDirection.OUTBOUND, deviceId, mockLineId, dest);
1398
+ webex.request.mockReturnValue(statusPayload);
1399
+
1400
+ // Move to S_SEND_CALL_SETUP
1401
+ dummyEvent = {
1402
+ type: 'E_SEND_CALL_SETUP',
1403
+ data: {
1404
+ seq: 1,
1405
+ message: {},
1406
+ type: 'OFFER'
1407
+ }
1408
+ };
1409
+ call.sendCallStateMachineEvt(dummyEvent);
1410
+ expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
1411
+
1412
+ // Complete media negotiation to allow connect -> established
1413
+ // Ask media SDK to initiate offer
1414
+ dummyEvent.type = 'E_SEND_ROAP_OFFER';
1415
+ dummyEvent.data = {
1416
+ seq: 1,
1417
+ messageType: 'OFFER',
1418
+ sdp: 'sdp'
1419
+ };
1420
+ call.sendMediaStateMachineEvt(dummyEvent);
1421
+ expect(call['mediaStateMachine'].state.value).toBe('S_SEND_ROAP_OFFER');
1422
+ dummyEvent.type = 'E_RECV_ROAP_ANSWER';
1423
+ dummyEvent.data = {
1424
+ seq: 1,
1425
+ messageType: 'ANSWER',
1426
+ sdp: 'sdp'
1427
+ };
1428
+ call.sendMediaStateMachineEvt(dummyEvent);
1429
+ expect(call['mediaStateMachine'].state.value).toBe('S_RECV_ROAP_ANSWER');
1430
+ // Send OK
1431
+ dummyOkEvent = {
1432
+ type: 'E_ROAP_OK',
1433
+ data: {
1434
+ received: false,
1435
+ message: {
1436
+ seq: 1,
1437
+ messageType: 'OK'
1438
+ }
1439
+ }
1440
+ };
1441
+ call.sendMediaStateMachineEvt(dummyOkEvent);
1442
+ expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_OK');
1443
+ expect(call['mediaNegotiationCompleted']).toBe(true);
1444
+
1445
+ // Move call to established
1446
+ dummyEvent.type = 'E_RECV_CALL_CONNECT';
1447
+ dummyEvent.data = undefined;
1448
+ call.sendCallStateMachineEvt(dummyEvent);
1449
+ expect(call['callStateMachine'].state.value).toBe('S_CALL_ESTABLISHED');
1450
+ emitSpy = jest.spyOn(call, 'emit');
1451
+ startCallerIdSpy = jest.spyOn(call, 'startCallerIdResolution'); // Now send progress with callerId while established via CallManager (Mobius event)
1452
+ mobiusProgressEvent = {
1453
+ id: 'evt1',
1454
+ timestamp: (0, _now.default)(),
1455
+ trackingId: 'track-1',
1456
+ data: {
1457
+ eventType: _types5.MobiusEventType.CALL_PROGRESS,
1458
+ callerId: {
1459
+ from: '"Bob Marley" <sip:5010@207.182.171.130;user=phone>;tag=888068389-1654853820619-'
1460
+ },
1461
+ callProgressData: {
1462
+ inbandMedia: true,
1463
+ alerting: false
1464
+ },
1465
+ callId: call.getCallId(),
1466
+ callUrl: 'https://mobius.example/call',
1467
+ deviceId: deviceId,
1468
+ correlationId: call.getCorrelationId()
1469
+ }
1470
+ };
1471
+ callManager['dequeueWsEvents'](mobiusProgressEvent);
1472
+
1473
+ // CallerId resolution should be triggered exactly once (handled by CallManager)
1474
+ expect(startCallerIdSpy).toBeCalledOnceWith(mobiusProgressEvent.data.callerId);
1475
+ // Since it returns early in established state, PROGRESS event should not be emitted here
1476
+ expect(emitSpy.mock.calls.find(function (args) {
1477
+ return args && args[0] === _types2.CALL_EVENT_KEYS.PROGRESS;
1478
+ })).toBeUndefined();
1479
+ expect(call['callStateMachine'].state.value).not.toBe('S_RECV_CALL_PROGRESS');
1480
+ // Early media flag should not be set due to early return
1481
+ expect(call.earlyMedia).not.toBe(true);
1482
+ case 1:
1483
+ case "end":
1484
+ return _context22.stop();
1485
+ }
1486
+ }, _callee22);
1487
+ })));
1488
+ it('state changes during unsuccessful incoming call due error in call connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1121
1489
  var warnSpy, errorSpy, stateMachineSpy, statusPayload, roapMessage;
1122
- return _regenerator.default.wrap(function (_context20) {
1123
- while (1) switch (_context20.prev = _context20.next) {
1490
+ return _regenerator.default.wrap(function (_context23) {
1491
+ while (1) switch (_context23.prev = _context23.next) {
1124
1492
  case 0:
1125
1493
  warnSpy = jest.spyOn(_Logger.default, 'warn');
1126
1494
  errorSpy = jest.spyOn(_Logger.default, 'error');
@@ -1147,7 +1515,7 @@ describe('State Machine handler tests', function () {
1147
1515
  webex.request.mockRejectedValueOnce({
1148
1516
  statusCode: 403
1149
1517
  }).mockResolvedValue(statusPayload);
1150
- _context20.next = 1;
1518
+ _context23.next = 1;
1151
1519
  return call['handleOutgoingCallConnect']({
1152
1520
  type: 'E_SEND_CALL_CONNECT'
1153
1521
  });
@@ -1158,14 +1526,14 @@ describe('State Machine handler tests', function () {
1158
1526
  expect(errorSpy).toBeCalledTimes(1);
1159
1527
  case 2:
1160
1528
  case "end":
1161
- return _context20.stop();
1529
+ return _context23.stop();
1162
1530
  }
1163
- }, _callee20);
1531
+ }, _callee23);
1164
1532
  })));
1165
- it('state changes during successful outgoing call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1533
+ it('state changes during successful outgoing call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1166
1534
  var statusPayload, dummyEvent, postMediaSpy, logSpy, dummyOkEvent;
1167
- return _regenerator.default.wrap(function (_context21) {
1168
- while (1) switch (_context21.prev = _context21.next) {
1535
+ return _regenerator.default.wrap(function (_context24) {
1536
+ while (1) switch (_context24.prev = _context24.next) {
1169
1537
  case 0:
1170
1538
  statusPayload = {
1171
1539
  statusCode: 200,
@@ -1241,14 +1609,14 @@ describe('State Machine handler tests', function () {
1241
1609
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
1242
1610
  case 1:
1243
1611
  case "end":
1244
- return _context21.stop();
1612
+ return _context24.stop();
1245
1613
  }
1246
- }, _callee21);
1614
+ }, _callee24);
1247
1615
  })));
1248
- it('outgoing call where we receive connect directly after setup. Media established before connect. test call and media state changes', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1616
+ it('outgoing call where we receive connect directly after setup. Media established before connect. test call and media state changes', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1249
1617
  var statusPayload, dummySetupEvent, dummyConnectEvent, dummyOfferEvent, dummyAnswerEvent, dummyOkEvent, postMediaSpy;
1250
- return _regenerator.default.wrap(function (_context22) {
1251
- while (1) switch (_context22.prev = _context22.next) {
1618
+ return _regenerator.default.wrap(function (_context25) {
1619
+ while (1) switch (_context25.prev = _context25.next) {
1252
1620
  case 0:
1253
1621
  statusPayload = {
1254
1622
  statusCode: 200,
@@ -1316,14 +1684,14 @@ describe('State Machine handler tests', function () {
1316
1684
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
1317
1685
  case 1:
1318
1686
  case "end":
1319
- return _context22.stop();
1687
+ return _context25.stop();
1320
1688
  }
1321
- }, _callee22);
1689
+ }, _callee25);
1322
1690
  })));
1323
- it('state changes during successful outgoing call with early media', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1324
- var statusPayload, dummyEvent;
1325
- return _regenerator.default.wrap(function (_context23) {
1326
- while (1) switch (_context23.prev = _context23.next) {
1691
+ it('state changes during successful outgoing call with early media', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1692
+ var statusPayload, dummyEvent;
1693
+ return _regenerator.default.wrap(function (_context26) {
1694
+ while (1) switch (_context26.prev = _context26.next) {
1327
1695
  case 0:
1328
1696
  statusPayload = {
1329
1697
  statusCode: 200,
@@ -1362,14 +1730,14 @@ describe('State Machine handler tests', function () {
1362
1730
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
1363
1731
  case 1:
1364
1732
  case "end":
1365
- return _context23.stop();
1733
+ return _context26.stop();
1366
1734
  }
1367
- }, _callee23);
1735
+ }, _callee26);
1368
1736
  })));
1369
- it('state changes during unsuccessful outgoing call due to error in call setup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1737
+ it('state changes during unsuccessful outgoing call due to error in call setup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1370
1738
  var statusPayload, dummyEvent, errorSpy;
1371
- return _regenerator.default.wrap(function (_context24) {
1372
- while (1) switch (_context24.prev = _context24.next) {
1739
+ return _regenerator.default.wrap(function (_context27) {
1740
+ while (1) switch (_context27.prev = _context27.next) {
1373
1741
  case 0:
1374
1742
  statusPayload = {
1375
1743
  statusCode: 403,
@@ -1386,25 +1754,31 @@ describe('State Machine handler tests', function () {
1386
1754
  webex.request.mockRejectedValueOnce(statusPayload);
1387
1755
  errorSpy = jest.spyOn(_Logger.default, 'error');
1388
1756
  call.sendCallStateMachineEvt(dummyEvent);
1389
- _context24.next = 1;
1757
+ _context27.next = 1;
1390
1758
  return (0, _testUtil.flushPromises)(3);
1391
1759
  case 1:
1760
+ _context27.next = 2;
1761
+ return _promise.default.resolve();
1762
+ case 2:
1763
+ _context27.next = 3;
1764
+ return _promise.default.resolve();
1765
+ case 3:
1392
1766
  expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
1393
1767
  expect(errorSpy).toHaveBeenCalled();
1394
1768
  expect(uploadLogsSpy).toHaveBeenCalledWith({
1395
1769
  correlationId: call.getCorrelationId(),
1396
1770
  callId: call.getCallId()
1397
1771
  });
1398
- case 2:
1772
+ case 4:
1399
1773
  case "end":
1400
- return _context24.stop();
1774
+ return _context27.stop();
1401
1775
  }
1402
- }, _callee24);
1776
+ }, _callee27);
1403
1777
  })));
1404
- it('state changes during unsuccessful outgoing call due to error in media ok', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1778
+ it('state changes during unsuccessful outgoing call due to error in media ok', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1405
1779
  var statusPayload, dummyEvent, warnSpy;
1406
- return _regenerator.default.wrap(function (_context25) {
1407
- while (1) switch (_context25.prev = _context25.next) {
1780
+ return _regenerator.default.wrap(function (_context28) {
1781
+ while (1) switch (_context28.prev = _context28.next) {
1408
1782
  case 0:
1409
1783
  statusPayload = {
1410
1784
  statusCode: 403,
@@ -1423,12 +1797,18 @@ describe('State Machine handler tests', function () {
1423
1797
  webex.request.mockRejectedValue(statusPayload);
1424
1798
  warnSpy = jest.spyOn(_Logger.default, 'warn');
1425
1799
  jest.spyOn(Utils, 'uploadLogs').mockResolvedValue(undefined);
1426
- _context25.next = 1;
1800
+ _context28.next = 1;
1427
1801
  return call['handleRoapEstablished']({}, dummyEvent);
1428
1802
  case 1:
1429
- _context25.next = 2;
1803
+ _context28.next = 2;
1430
1804
  return (0, _testUtil.flushPromises)(2);
1431
1805
  case 2:
1806
+ _context28.next = 3;
1807
+ return _promise.default.resolve();
1808
+ case 3:
1809
+ _context28.next = 4;
1810
+ return _promise.default.resolve();
1811
+ case 4:
1432
1812
  expect(call.isConnected()).toBe(false);
1433
1813
  expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_TEARDOWN');
1434
1814
  expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
@@ -1440,16 +1820,16 @@ describe('State Machine handler tests', function () {
1440
1820
  file: 'call',
1441
1821
  method: 'handleRoapError'
1442
1822
  });
1443
- case 3:
1823
+ case 5:
1444
1824
  case "end":
1445
- return _context25.stop();
1825
+ return _context28.stop();
1446
1826
  }
1447
- }, _callee25);
1827
+ }, _callee28);
1448
1828
  })));
1449
- it('state changes during unsuccessful outgoing call since no sdp in offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1829
+ it('state changes during unsuccessful outgoing call since no sdp in offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1450
1830
  var statusPayload, dummyEvent;
1451
- return _regenerator.default.wrap(function (_context26) {
1452
- while (1) switch (_context26.prev = _context26.next) {
1831
+ return _regenerator.default.wrap(function (_context29) {
1832
+ while (1) switch (_context29.prev = _context29.next) {
1453
1833
  case 0:
1454
1834
  statusPayload = {
1455
1835
  statusCode: 403,
@@ -1472,14 +1852,14 @@ describe('State Machine handler tests', function () {
1472
1852
  expect(_testUtil.mediaConnection.initiateOffer).toBeCalledOnceWith();
1473
1853
  case 1:
1474
1854
  case "end":
1475
- return _context26.stop();
1855
+ return _context29.stop();
1476
1856
  }
1477
- }, _callee26);
1857
+ }, _callee29);
1478
1858
  })));
1479
- it('Outgoing Roap offer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1859
+ it('Outgoing Roap offer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1480
1860
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1481
- return _regenerator.default.wrap(function (_context27) {
1482
- while (1) switch (_context27.prev = _context27.next) {
1861
+ return _regenerator.default.wrap(function (_context30) {
1862
+ while (1) switch (_context30.prev = _context30.next) {
1483
1863
  case 0:
1484
1864
  statusPayload = {
1485
1865
  statusCode: 503,
@@ -1501,7 +1881,7 @@ describe('State Machine handler tests', function () {
1501
1881
  }
1502
1882
  };
1503
1883
  call['connected'] = true;
1504
- _context27.next = 1;
1884
+ _context30.next = 1;
1505
1885
  return call['handleOutgoingRoapOffer']({}, dummyEvent);
1506
1886
  case 1:
1507
1887
  jest.advanceTimersByTime(1005);
@@ -1513,14 +1893,14 @@ describe('State Machine handler tests', function () {
1513
1893
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1514
1894
  case 2:
1515
1895
  case "end":
1516
- return _context27.stop();
1896
+ return _context30.stop();
1517
1897
  }
1518
- }, _callee27);
1898
+ }, _callee30);
1519
1899
  })));
1520
- it('Outgoing Roap offer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1900
+ it('Outgoing Roap offer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1521
1901
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1522
- return _regenerator.default.wrap(function (_context28) {
1523
- while (1) switch (_context28.prev = _context28.next) {
1902
+ return _regenerator.default.wrap(function (_context31) {
1903
+ while (1) switch (_context31.prev = _context31.next) {
1524
1904
  case 0:
1525
1905
  statusPayload = {
1526
1906
  statusCode: 503,
@@ -1542,7 +1922,7 @@ describe('State Machine handler tests', function () {
1542
1922
  }
1543
1923
  };
1544
1924
  call['connected'] = false;
1545
- _context28.next = 1;
1925
+ _context31.next = 1;
1546
1926
  return call['handleOutgoingRoapOffer']({}, dummyEvent);
1547
1927
  case 1:
1548
1928
  jest.advanceTimersByTime(1005);
@@ -1553,14 +1933,14 @@ describe('State Machine handler tests', function () {
1553
1933
  expect(stateMachineSpy).not.toBeCalled();
1554
1934
  case 2:
1555
1935
  case "end":
1556
- return _context28.stop();
1936
+ return _context31.stop();
1557
1937
  }
1558
- }, _callee28);
1938
+ }, _callee31);
1559
1939
  })));
1560
- it('Outgoing Roap Answer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1940
+ it('Outgoing Roap Answer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1561
1941
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1562
- return _regenerator.default.wrap(function (_context29) {
1563
- while (1) switch (_context29.prev = _context29.next) {
1942
+ return _regenerator.default.wrap(function (_context32) {
1943
+ while (1) switch (_context32.prev = _context32.next) {
1564
1944
  case 0:
1565
1945
  statusPayload = {
1566
1946
  statusCode: 503,
@@ -1582,7 +1962,7 @@ describe('State Machine handler tests', function () {
1582
1962
  };
1583
1963
  call['connected'] = true;
1584
1964
  call['mediaStateMachine'].state.value = 'S_RECV_ROAP_OFFER';
1585
- _context29.next = 1;
1965
+ _context32.next = 1;
1586
1966
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
1587
1967
  case 1:
1588
1968
  jest.advanceTimersByTime(1005);
@@ -1594,14 +1974,14 @@ describe('State Machine handler tests', function () {
1594
1974
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1595
1975
  case 2:
1596
1976
  case "end":
1597
- return _context29.stop();
1977
+ return _context32.stop();
1598
1978
  }
1599
- }, _callee29);
1979
+ }, _callee32);
1600
1980
  })));
1601
- it('Outgoing Roap answer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1981
+ it('Outgoing Roap answer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
1602
1982
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1603
- return _regenerator.default.wrap(function (_context30) {
1604
- while (1) switch (_context30.prev = _context30.next) {
1983
+ return _regenerator.default.wrap(function (_context33) {
1984
+ while (1) switch (_context33.prev = _context33.next) {
1605
1985
  case 0:
1606
1986
  statusPayload = {
1607
1987
  statusCode: 503,
@@ -1622,7 +2002,7 @@ describe('State Machine handler tests', function () {
1622
2002
  }
1623
2003
  };
1624
2004
  call['connected'] = false;
1625
- _context30.next = 1;
2005
+ _context33.next = 1;
1626
2006
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
1627
2007
  case 1:
1628
2008
  jest.advanceTimersByTime(1005);
@@ -1634,14 +2014,14 @@ describe('State Machine handler tests', function () {
1634
2014
  expect(stateMachineSpy).not.toBeCalled();
1635
2015
  case 2:
1636
2016
  case "end":
1637
- return _context30.stop();
2017
+ return _context33.stop();
1638
2018
  }
1639
- }, _callee30);
2019
+ }, _callee33);
1640
2020
  })));
1641
- it('ROAP error during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
2021
+ it('ROAP error during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
1642
2022
  var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
1643
- return _regenerator.default.wrap(function (_context31) {
1644
- while (1) switch (_context31.prev = _context31.next) {
2023
+ return _regenerator.default.wrap(function (_context34) {
2024
+ while (1) switch (_context34.prev = _context34.next) {
1645
2025
  case 0:
1646
2026
  statusPayload = {
1647
2027
  statusCode: 200,
@@ -1666,14 +2046,14 @@ describe('State Machine handler tests', function () {
1666
2046
  expect(stateMachineSpy).not.toHaveBeenCalled();
1667
2047
  case 1:
1668
2048
  case "end":
1669
- return _context31.stop();
2049
+ return _context34.stop();
1670
2050
  }
1671
- }, _callee31);
2051
+ }, _callee34);
1672
2052
  })));
1673
- it('ROAP ok retry-after during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
2053
+ it('ROAP ok retry-after during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
1674
2054
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1675
- return _regenerator.default.wrap(function (_context32) {
1676
- while (1) switch (_context32.prev = _context32.next) {
2055
+ return _regenerator.default.wrap(function (_context35) {
2056
+ while (1) switch (_context35.prev = _context35.next) {
1677
2057
  case 0:
1678
2058
  statusPayload = {
1679
2059
  statusCode: 503,
@@ -1695,7 +2075,7 @@ describe('State Machine handler tests', function () {
1695
2075
  };
1696
2076
  call['connected'] = true;
1697
2077
  call['mediaStateMachine'].state.value = 'S_RECV_ROAP_ANSWER';
1698
- _context32.next = 1;
2078
+ _context35.next = 1;
1699
2079
  return call['handleRoapEstablished']({}, dummyEvent);
1700
2080
  case 1:
1701
2081
  jest.advanceTimersByTime(1005);
@@ -1707,14 +2087,14 @@ describe('State Machine handler tests', function () {
1707
2087
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1708
2088
  case 2:
1709
2089
  case "end":
1710
- return _context32.stop();
2090
+ return _context35.stop();
1711
2091
  }
1712
- }, _callee32);
2092
+ }, _callee35);
1713
2093
  })));
1714
- it('Unable to communicate roap error with mobius', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
2094
+ it('Unable to communicate roap error with mobius', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
1715
2095
  var statusPayload, stateMachineSpy, funcSpy, errorEvent;
1716
- return _regenerator.default.wrap(function (_context33) {
1717
- while (1) switch (_context33.prev = _context33.next) {
2096
+ return _regenerator.default.wrap(function (_context36) {
2097
+ while (1) switch (_context36.prev = _context36.next) {
1718
2098
  case 0:
1719
2099
  statusPayload = {
1720
2100
  statusCode: 403,
@@ -1737,14 +2117,14 @@ describe('State Machine handler tests', function () {
1737
2117
  expect(stateMachineSpy).not.toHaveBeenCalled();
1738
2118
  case 1:
1739
2119
  case "end":
1740
- return _context33.stop();
2120
+ return _context36.stop();
1741
2121
  }
1742
- }, _callee33);
2122
+ }, _callee36);
1743
2123
  })));
1744
- it('ROAP error during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
2124
+ it('ROAP error during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
1745
2125
  var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
1746
- return _regenerator.default.wrap(function (_context34) {
1747
- while (1) switch (_context34.prev = _context34.next) {
2126
+ return _regenerator.default.wrap(function (_context37) {
2127
+ while (1) switch (_context37.prev = _context37.next) {
1748
2128
  case 0:
1749
2129
  statusPayload = {
1750
2130
  statusCode: 200,
@@ -1762,7 +2142,7 @@ describe('State Machine handler tests', function () {
1762
2142
  }
1763
2143
  };
1764
2144
  call['connected'] = false;
1765
- _context34.next = 1;
2145
+ _context37.next = 1;
1766
2146
  return call['handleRoapError']({}, errorEvent);
1767
2147
  case 1:
1768
2148
  expect(funcSpy).toBeCalledOnceWith(errorEvent.data);
@@ -1778,14 +2158,14 @@ describe('State Machine handler tests', function () {
1778
2158
  });
1779
2159
  case 2:
1780
2160
  case "end":
1781
- return _context34.stop();
2161
+ return _context37.stop();
1782
2162
  }
1783
- }, _callee34);
2163
+ }, _callee37);
1784
2164
  })));
1785
- it('incoming call: failing ROAP_ANSWER posts error path and tears down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
2165
+ it('incoming call: failing ROAP_ANSWER posts error path and tears down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
1786
2166
  var statusPayload, warnSpy, postMediaSpy, setupEvent, connectEvent, offerEvent, answerEvent;
1787
- return _regenerator.default.wrap(function (_context35) {
1788
- while (1) switch (_context35.prev = _context35.next) {
2167
+ return _regenerator.default.wrap(function (_context38) {
2168
+ while (1) switch (_context38.prev = _context38.next) {
1789
2169
  case 0:
1790
2170
  statusPayload = {
1791
2171
  statusCode: 403,
@@ -1823,12 +2203,18 @@ describe('State Machine handler tests', function () {
1823
2203
  messageType: 'ANSWER'
1824
2204
  }
1825
2205
  };
1826
- _context35.next = 1;
2206
+ _context38.next = 1;
1827
2207
  return call.sendMediaStateMachineEvt(answerEvent);
1828
2208
  case 1:
1829
- _context35.next = 2;
2209
+ _context38.next = 2;
1830
2210
  return (0, _testUtil.flushPromises)(2);
1831
2211
  case 2:
2212
+ _context38.next = 3;
2213
+ return _promise.default.resolve();
2214
+ case 3:
2215
+ _context38.next = 4;
2216
+ return _promise.default.resolve();
2217
+ case 4:
1832
2218
  expect(postMediaSpy).toBeCalledOnceWith(answerEvent.data);
1833
2219
  expect(warnSpy).toHaveBeenCalledWith('Failed to send MediaAnswer request', {
1834
2220
  file: 'call',
@@ -1842,16 +2228,16 @@ describe('State Machine handler tests', function () {
1842
2228
  // Final state should be torn down and cleared for unconnected call
1843
2229
  expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_TEARDOWN');
1844
2230
  expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1845
- case 3:
2231
+ case 5:
1846
2232
  case "end":
1847
- return _context35.stop();
2233
+ return _context38.stop();
1848
2234
  }
1849
- }, _callee35);
2235
+ }, _callee38);
1850
2236
  })));
1851
- it('state changes during successful incoming call with out of order events', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
2237
+ it('state changes during successful incoming call with out of order events', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
1852
2238
  var statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
1853
- return _regenerator.default.wrap(function (_context36) {
1854
- while (1) switch (_context36.prev = _context36.next) {
2239
+ return _regenerator.default.wrap(function (_context39) {
2240
+ while (1) switch (_context39.prev = _context39.next) {
1855
2241
  case 0:
1856
2242
  statusPayload = {
1857
2243
  statusCode: 200,
@@ -1884,7 +2270,7 @@ describe('State Machine handler tests', function () {
1884
2270
  seq: 1,
1885
2271
  messageType: 'ANSWER'
1886
2272
  };
1887
- _context36.next = 1;
2273
+ _context39.next = 1;
1888
2274
  return call.sendMediaStateMachineEvt(dummyEvent);
1889
2275
  case 1:
1890
2276
  expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
@@ -1906,7 +2292,7 @@ describe('State Machine handler tests', function () {
1906
2292
  seq: 2,
1907
2293
  messageType: 'OFFER_REQUEST'
1908
2294
  };
1909
- _context36.next = 2;
2295
+ _context39.next = 2;
1910
2296
  return call.sendMediaStateMachineEvt(dummyEvent);
1911
2297
  case 2:
1912
2298
  expect(call['receivedRoapOKSeq']).toBe(0);
@@ -1956,7 +2342,7 @@ describe('State Machine handler tests', function () {
1956
2342
  };
1957
2343
  call.sendCallStateMachineEvt(dummyEvent);
1958
2344
  dummyEvent.type = 'E_RECV_ROAP_OFFER';
1959
- _context36.next = 3;
2345
+ _context39.next = 3;
1960
2346
  return call.sendMediaStateMachineEvt(dummyEvent);
1961
2347
  case 3:
1962
2348
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1965,7 +2351,7 @@ describe('State Machine handler tests', function () {
1965
2351
  seq: 3,
1966
2352
  messageType: 'ANSWER'
1967
2353
  };
1968
- _context36.next = 4;
2354
+ _context39.next = 4;
1969
2355
  return call.sendMediaStateMachineEvt(dummyEvent);
1970
2356
  case 4:
1971
2357
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1984,7 +2370,7 @@ describe('State Machine handler tests', function () {
1984
2370
  messageType: 'OK'
1985
2371
  }
1986
2372
  };
1987
- _context36.next = 5;
2373
+ _context39.next = 5;
1988
2374
  return call.sendMediaStateMachineEvt(dummyOkEvent);
1989
2375
  case 5:
1990
2376
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(6, dummyOkEvent.data.message);
@@ -1999,14 +2385,14 @@ describe('State Machine handler tests', function () {
1999
2385
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
2000
2386
  case 6:
2001
2387
  case "end":
2002
- return _context36.stop();
2388
+ return _context39.stop();
2003
2389
  }
2004
- }, _callee36);
2390
+ }, _callee39);
2005
2391
  })));
2006
- it('successfully handles out of order events when ROAP OK is received while executing outgoingRoapAnswer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
2392
+ it('successfully handles out of order events when ROAP OK is received while executing outgoingRoapAnswer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
2007
2393
  var mockStatusBody, statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
2008
- return _regenerator.default.wrap(function (_context37) {
2009
- while (1) switch (_context37.prev = _context37.next) {
2394
+ return _regenerator.default.wrap(function (_context40) {
2395
+ while (1) switch (_context40.prev = _context40.next) {
2010
2396
  case 0:
2011
2397
  mockStatusBody = {
2012
2398
  device: {
@@ -2046,7 +2432,7 @@ describe('State Machine handler tests', function () {
2046
2432
  seq: 1,
2047
2433
  messageType: 'ANSWER'
2048
2434
  };
2049
- _context37.next = 1;
2435
+ _context40.next = 1;
2050
2436
  return call.sendMediaStateMachineEvt(dummyEvent);
2051
2437
  case 1:
2052
2438
  expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
@@ -2068,7 +2454,7 @@ describe('State Machine handler tests', function () {
2068
2454
  seq: 2,
2069
2455
  messageType: 'OFFER_REQUEST'
2070
2456
  };
2071
- _context37.next = 2;
2457
+ _context40.next = 2;
2072
2458
  return call.sendMediaStateMachineEvt(dummyEvent);
2073
2459
  case 2:
2074
2460
  expect(call['receivedRoapOKSeq']).toBe(0);
@@ -2118,7 +2504,7 @@ describe('State Machine handler tests', function () {
2118
2504
  };
2119
2505
  call.sendCallStateMachineEvt(dummyEvent);
2120
2506
  dummyEvent.type = 'E_RECV_ROAP_OFFER';
2121
- _context37.next = 3;
2507
+ _context40.next = 3;
2122
2508
  return call.sendMediaStateMachineEvt(dummyEvent);
2123
2509
  case 3:
2124
2510
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -2127,7 +2513,7 @@ describe('State Machine handler tests', function () {
2127
2513
  seq: 3,
2128
2514
  messageType: 'ANSWER'
2129
2515
  };
2130
- _context37.next = 4;
2516
+ _context40.next = 4;
2131
2517
  return call.sendMediaStateMachineEvt(dummyEvent);
2132
2518
  case 4:
2133
2519
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -2144,7 +2530,7 @@ describe('State Machine handler tests', function () {
2144
2530
  }
2145
2531
  };
2146
2532
  call.sendMediaStateMachineEvt(dummyEvent);
2147
- _context37.next = 5;
2533
+ _context40.next = 5;
2148
2534
  return call.sendMediaStateMachineEvt(dummyOkEvent);
2149
2535
  case 5:
2150
2536
  expect(call['receivedRoapOKSeq']).toBe(3);
@@ -2160,14 +2546,14 @@ describe('State Machine handler tests', function () {
2160
2546
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
2161
2547
  case 6:
2162
2548
  case "end":
2163
- return _context37.stop();
2549
+ return _context40.stop();
2164
2550
  }
2165
- }, _callee37);
2551
+ }, _callee40);
2166
2552
  })));
2167
- it('handle hold event successfully when media received after progress but before connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
2553
+ it('handle hold event successfully when media received after progress but before connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
2168
2554
  var statusPayload, dummyEvent, postMediaSpy, infoSpy, dummyOkEvent;
2169
- return _regenerator.default.wrap(function (_context38) {
2170
- while (1) switch (_context38.prev = _context38.next) {
2555
+ return _regenerator.default.wrap(function (_context41) {
2556
+ while (1) switch (_context41.prev = _context41.next) {
2171
2557
  case 0:
2172
2558
  statusPayload = {
2173
2559
  statusCode: 200,
@@ -2228,20 +2614,20 @@ describe('State Machine handler tests', function () {
2228
2614
  dummyEvent.data = undefined;
2229
2615
  call.sendCallStateMachineEvt(dummyEvent);
2230
2616
  expect(call['callStateMachine'].state.value).toBe('S_CALL_HOLD');
2231
- expect(infoSpy).toHaveBeenLastCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with: ").concat(call.getCorrelationId()), {
2617
+ expect(infoSpy).toHaveBeenCalledWith("".concat(_constants2.METHOD_START_MESSAGE, " with: ").concat(call.getCorrelationId()), {
2232
2618
  file: 'call',
2233
2619
  method: 'handleCallHold'
2234
2620
  });
2235
2621
  case 1:
2236
2622
  case "end":
2237
- return _context38.stop();
2623
+ return _context41.stop();
2238
2624
  }
2239
- }, _callee38);
2625
+ }, _callee41);
2240
2626
  })));
2241
- it('emits DISCONNECT before mobius delete request is invoked', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
2627
+ it('emits DISCONNECT before mobius delete request is invoked', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
2242
2628
  var emitSpy, deleteSpy;
2243
- return _regenerator.default.wrap(function (_context39) {
2244
- while (1) switch (_context39.prev = _context39.next) {
2629
+ return _regenerator.default.wrap(function (_context42) {
2630
+ while (1) switch (_context42.prev = _context42.next) {
2245
2631
  case 0:
2246
2632
  emitSpy = jest.spyOn(call, 'emit');
2247
2633
  deleteSpy = jest.spyOn(call, 'delete').mockResolvedValue({
@@ -2250,7 +2636,7 @@ describe('State Machine handler tests', function () {
2250
2636
  call.sendCallStateMachineEvt({
2251
2637
  type: 'E_RECV_CALL_DISCONNECT'
2252
2638
  });
2253
- _context39.next = 1;
2639
+ _context42.next = 1;
2254
2640
  return (0, _testUtil.flushPromises)(1);
2255
2641
  case 1:
2256
2642
  expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
@@ -2258,9 +2644,9 @@ describe('State Machine handler tests', function () {
2258
2644
  expect(emitSpy.mock.invocationCallOrder[0]).toBeLessThan(deleteSpy.mock.invocationCallOrder[0]);
2259
2645
  case 2:
2260
2646
  case "end":
2261
- return _context39.stop();
2647
+ return _context42.stop();
2262
2648
  }
2263
- }, _callee39);
2649
+ }, _callee42);
2264
2650
  })));
2265
2651
  describe('Call event timers tests', function () {
2266
2652
  var callManager;
@@ -2271,10 +2657,10 @@ describe('State Machine handler tests', function () {
2271
2657
  afterEach(function () {
2272
2658
  jest.clearAllTimers();
2273
2659
  });
2274
- it('times out if the next event is not received - 60 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
2660
+ it('times out if the next event is not received - 60 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
2275
2661
  var statusPayload, dummyEvent, logSpy, emitSpy, deleteSpy, dummyOkEvent;
2276
- return _regenerator.default.wrap(function (_context40) {
2277
- while (1) switch (_context40.prev = _context40.next) {
2662
+ return _regenerator.default.wrap(function (_context43) {
2663
+ while (1) switch (_context43.prev = _context43.next) {
2278
2664
  case 0:
2279
2665
  statusPayload = {
2280
2666
  statusCode: 200,
@@ -2291,7 +2677,7 @@ describe('State Machine handler tests', function () {
2291
2677
  webex.request.mockReturnValue(statusPayload);
2292
2678
 
2293
2679
  // handleOutgoingCallSetup is asynchronous
2294
- _context40.next = 1;
2680
+ _context43.next = 1;
2295
2681
  return call.sendCallStateMachineEvt(dummyEvent);
2296
2682
  case 1:
2297
2683
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
@@ -2334,14 +2720,14 @@ describe('State Machine handler tests', function () {
2334
2720
  expect(callManager.callCollection).toStrictEqual({});
2335
2721
  case 2:
2336
2722
  case "end":
2337
- return _context40.stop();
2723
+ return _context43.stop();
2338
2724
  }
2339
- }, _callee40);
2725
+ }, _callee43);
2340
2726
  })));
2341
- it('times out if the next event is not received - 10 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
2727
+ it('times out if the next event is not received - 10 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
2342
2728
  var statusPayload, dummyEvent, call, emitSpy, deleteSpy, logSpy;
2343
- return _regenerator.default.wrap(function (_context41) {
2344
- while (1) switch (_context41.prev = _context41.next) {
2729
+ return _regenerator.default.wrap(function (_context44) {
2730
+ while (1) switch (_context44.prev = _context44.next) {
2345
2731
  case 0:
2346
2732
  statusPayload = {
2347
2733
  statusCode: 200,
@@ -2360,7 +2746,7 @@ describe('State Machine handler tests', function () {
2360
2746
  expect((0, _keys.default)(callManager.callCollection)[0]).toBe(call.getCorrelationId());
2361
2747
 
2362
2748
  // handleOutgoingCallSetup is asynchronous
2363
- _context41.next = 1;
2749
+ _context44.next = 1;
2364
2750
  return call.sendCallStateMachineEvt(dummyEvent);
2365
2751
  case 1:
2366
2752
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
@@ -2372,9 +2758,9 @@ describe('State Machine handler tests', function () {
2372
2758
  expect(callManager.callCollection).toStrictEqual({});
2373
2759
  case 2:
2374
2760
  case "end":
2375
- return _context41.stop();
2761
+ return _context44.stop();
2376
2762
  }
2377
- }, _callee41);
2763
+ }, _callee44);
2378
2764
  })));
2379
2765
  });
2380
2766
  });
@@ -2393,6 +2779,11 @@ describe('Supplementary Services tests', function () {
2393
2779
  };
2394
2780
  var call;
2395
2781
  beforeEach(function () {
2782
+ _request.APIRequest.resetInstance();
2783
+ _request.APIRequest.getInstance({
2784
+ webex: webex,
2785
+ isMobiusSocketEnabled: false
2786
+ });
2396
2787
  /* Since we are not actually testing from the start of a call , so it's good to set the below
2397
2788
  * parameters manually
2398
2789
  */
@@ -2434,10 +2825,10 @@ describe('Supplementary Services tests', function () {
2434
2825
  beforeEach(function () {
2435
2826
  call.removeAllListeners();
2436
2827
  });
2437
- it('Handle successful Call hold case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
2828
+ it('Handle successful Call hold case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
2438
2829
  var responsePayload, warnSpy, roapEvent;
2439
- return _regenerator.default.wrap(function (_context43) {
2440
- while (1) switch (_context43.prev = _context43.next) {
2830
+ return _regenerator.default.wrap(function (_context46) {
2831
+ while (1) switch (_context46.prev = _context46.next) {
2441
2832
  case 0:
2442
2833
  expect.assertions(7);
2443
2834
  responsePayload = {
@@ -2450,25 +2841,25 @@ describe('Supplementary Services tests', function () {
2450
2841
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2451
2842
  call['held'] = false;
2452
2843
  call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
2453
- var _ref43 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42(correlationId) {
2454
- return _regenerator.default.wrap(function (_context42) {
2455
- while (1) switch (_context42.prev = _context42.next) {
2844
+ var _ref54 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(correlationId) {
2845
+ return _regenerator.default.wrap(function (_context45) {
2846
+ while (1) switch (_context45.prev = _context45.next) {
2456
2847
  case 0:
2457
2848
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2458
2849
  case 1:
2459
2850
  case "end":
2460
- return _context42.stop();
2851
+ return _context45.stop();
2461
2852
  }
2462
- }, _callee42);
2853
+ }, _callee45);
2463
2854
  }));
2464
2855
  return function (_x) {
2465
- return _ref43.apply(this, arguments);
2856
+ return _ref54.apply(this, arguments);
2466
2857
  };
2467
2858
  }());
2468
- _context43.next = 1;
2859
+ _context46.next = 1;
2469
2860
  return call.doHoldResume();
2470
2861
  case 1:
2471
- _context43.next = 2;
2862
+ _context46.next = 2;
2472
2863
  return (0, _testUtil.flushPromises)(2);
2473
2864
  case 2:
2474
2865
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2484,11 +2875,11 @@ describe('Supplementary Services tests', function () {
2484
2875
  call['handleIncomingRoapOffer']({}, dummyEvent);
2485
2876
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2486
2877
  roapEvent.data.type = 'ANSWER';
2487
- _context43.next = 3;
2878
+ _context46.next = 3;
2488
2879
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2489
2880
  case 3:
2490
2881
  roapEvent.data.type = 'OK';
2491
- _context43.next = 4;
2882
+ _context46.next = 4;
2492
2883
  return call['handleRoapEstablished']({}, dummyEvent);
2493
2884
  case 4:
2494
2885
  expect(clearTimeout).toHaveBeenCalledTimes(1);
@@ -2503,14 +2894,14 @@ describe('Supplementary Services tests', function () {
2503
2894
  });
2504
2895
  case 5:
2505
2896
  case "end":
2506
- return _context43.stop();
2897
+ return _context46.stop();
2507
2898
  }
2508
- }, _callee43);
2899
+ }, _callee46);
2509
2900
  })));
2510
- it('Handle successful Call hold case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45() {
2901
+ it('Handle successful Call hold case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
2511
2902
  var responsePayload, warnSpy, roapEvent;
2512
- return _regenerator.default.wrap(function (_context45) {
2513
- while (1) switch (_context45.prev = _context45.next) {
2903
+ return _regenerator.default.wrap(function (_context48) {
2904
+ while (1) switch (_context48.prev = _context48.next) {
2514
2905
  case 0:
2515
2906
  expect.assertions(8);
2516
2907
  responsePayload = {
@@ -2523,26 +2914,26 @@ describe('Supplementary Services tests', function () {
2523
2914
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2524
2915
  call['held'] = false;
2525
2916
  call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
2526
- var _ref45 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44(correlationId) {
2527
- return _regenerator.default.wrap(function (_context44) {
2528
- while (1) switch (_context44.prev = _context44.next) {
2917
+ var _ref56 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47(correlationId) {
2918
+ return _regenerator.default.wrap(function (_context47) {
2919
+ while (1) switch (_context47.prev = _context47.next) {
2529
2920
  case 0:
2530
2921
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2531
2922
  case 1:
2532
2923
  case "end":
2533
- return _context44.stop();
2924
+ return _context47.stop();
2534
2925
  }
2535
- }, _callee44);
2926
+ }, _callee47);
2536
2927
  }));
2537
2928
  return function (_x2) {
2538
- return _ref45.apply(this, arguments);
2929
+ return _ref56.apply(this, arguments);
2539
2930
  };
2540
2931
  }());
2541
2932
  call.doHoldResume();
2542
- _context45.next = 1;
2933
+ _context48.next = 1;
2543
2934
  return _promise.default.resolve();
2544
2935
  case 1:
2545
- _context45.next = 2;
2936
+ _context48.next = 2;
2546
2937
  return _promise.default.resolve();
2547
2938
  case 2:
2548
2939
  expect(setTimeout).not.toHaveBeenCalled();
@@ -2558,11 +2949,11 @@ describe('Supplementary Services tests', function () {
2558
2949
  call['handleIncomingRoapOffer']({}, dummyEvent);
2559
2950
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2560
2951
  roapEvent.data.type = 'ANSWER';
2561
- _context45.next = 3;
2952
+ _context48.next = 3;
2562
2953
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2563
2954
  case 3:
2564
2955
  roapEvent.data.type = 'OK';
2565
- _context45.next = 4;
2956
+ _context48.next = 4;
2566
2957
  return call['handleRoapEstablished']({}, dummyEvent);
2567
2958
  case 4:
2568
2959
  expect(clearTimeout).not.toHaveBeenCalled();
@@ -2577,14 +2968,14 @@ describe('Supplementary Services tests', function () {
2577
2968
  });
2578
2969
  case 5:
2579
2970
  case "end":
2580
- return _context45.stop();
2971
+ return _context48.stop();
2581
2972
  }
2582
- }, _callee45);
2973
+ }, _callee48);
2583
2974
  })));
2584
- it('Handle failure Call Hold case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
2975
+ it('Handle failure Call Hold case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
2585
2976
  var responsePayload;
2586
- return _regenerator.default.wrap(function (_context47) {
2587
- while (1) switch (_context47.prev = _context47.next) {
2977
+ return _regenerator.default.wrap(function (_context50) {
2978
+ while (1) switch (_context50.prev = _context50.next) {
2588
2979
  case 0:
2589
2980
  expect.assertions(4);
2590
2981
  responsePayload = {
@@ -2594,26 +2985,26 @@ describe('Supplementary Services tests', function () {
2594
2985
  jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
2595
2986
  call['held'] = false;
2596
2987
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2597
- var _ref47 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46(errObj) {
2598
- return _regenerator.default.wrap(function (_context46) {
2599
- while (1) switch (_context46.prev = _context46.next) {
2988
+ var _ref58 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49(errObj) {
2989
+ return _regenerator.default.wrap(function (_context49) {
2990
+ while (1) switch (_context49.prev = _context49.next) {
2600
2991
  case 0:
2601
2992
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2602
2993
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2603
2994
  case 1:
2604
2995
  case "end":
2605
- return _context46.stop();
2996
+ return _context49.stop();
2606
2997
  }
2607
- }, _callee46);
2998
+ }, _callee49);
2608
2999
  }));
2609
3000
  return function (_x3) {
2610
- return _ref47.apply(this, arguments);
3001
+ return _ref58.apply(this, arguments);
2611
3002
  };
2612
3003
  }());
2613
- _context47.next = 1;
3004
+ _context50.next = 1;
2614
3005
  return call.doHoldResume();
2615
3006
  case 1:
2616
- _context47.next = 2;
3007
+ _context50.next = 2;
2617
3008
  return (0, _testUtil.flushPromises)(2);
2618
3009
  case 2:
2619
3010
  expect(call.isHeld()).toStrictEqual(false);
@@ -2623,14 +3014,14 @@ describe('Supplementary Services tests', function () {
2623
3014
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2624
3015
  case 3:
2625
3016
  case "end":
2626
- return _context47.stop();
3017
+ return _context50.stop();
2627
3018
  }
2628
- }, _callee47);
3019
+ }, _callee50);
2629
3020
  })));
2630
- it('Handle failure Call Hold case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
3021
+ it('Handle failure Call Hold case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
2631
3022
  var responsePayload, rejectPayload, roapEvent;
2632
- return _regenerator.default.wrap(function (_context49) {
2633
- while (1) switch (_context49.prev = _context49.next) {
3023
+ return _regenerator.default.wrap(function (_context52) {
3024
+ while (1) switch (_context52.prev = _context52.next) {
2634
3025
  case 0:
2635
3026
  expect.assertions(5);
2636
3027
  responsePayload = {
@@ -2644,24 +3035,24 @@ describe('Supplementary Services tests', function () {
2644
3035
  jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
2645
3036
  call['held'] = false;
2646
3037
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2647
- var _ref49 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48(errObj) {
2648
- return _regenerator.default.wrap(function (_context48) {
2649
- while (1) switch (_context48.prev = _context48.next) {
3038
+ var _ref60 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51(errObj) {
3039
+ return _regenerator.default.wrap(function (_context51) {
3040
+ while (1) switch (_context51.prev = _context51.next) {
2650
3041
  case 0:
2651
3042
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2652
3043
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2653
3044
  case 1:
2654
3045
  case "end":
2655
- return _context48.stop();
3046
+ return _context51.stop();
2656
3047
  }
2657
- }, _callee48);
3048
+ }, _callee51);
2658
3049
  }));
2659
3050
  return function (_x4) {
2660
- return _ref49.apply(this, arguments);
3051
+ return _ref60.apply(this, arguments);
2661
3052
  };
2662
3053
  }());
2663
3054
  call.doHoldResume();
2664
- _context49.next = 1;
3055
+ _context52.next = 1;
2665
3056
  return (0, _testUtil.flushPromises)(2);
2666
3057
  case 1:
2667
3058
  /* the Call State should transition to S_CALL_ESTABLISHED
@@ -2671,7 +3062,7 @@ describe('Supplementary Services tests', function () {
2671
3062
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2672
3063
  /* We are intentionally failing the ROAP ANSWER */
2673
3064
  roapEvent.data.type = 'ANSWER';
2674
- _context49.next = 2;
3065
+ _context52.next = 2;
2675
3066
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2676
3067
  case 2:
2677
3068
  expect(call.isHeld()).toStrictEqual(false);
@@ -2679,14 +3070,14 @@ describe('Supplementary Services tests', function () {
2679
3070
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2680
3071
  case 3:
2681
3072
  case "end":
2682
- return _context49.stop();
3073
+ return _context52.stop();
2683
3074
  }
2684
- }, _callee49);
3075
+ }, _callee52);
2685
3076
  })));
2686
- it('Handle failure Call Hold case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
3077
+ it('Handle failure Call Hold case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
2687
3078
  var responsePayload, warnSpy, roapEvent;
2688
- return _regenerator.default.wrap(function (_context50) {
2689
- while (1) switch (_context50.prev = _context50.next) {
3079
+ return _regenerator.default.wrap(function (_context53) {
3080
+ while (1) switch (_context53.prev = _context53.next) {
2690
3081
  case 0:
2691
3082
  responsePayload = {
2692
3083
  statusCode: 200,
@@ -2697,10 +3088,10 @@ describe('Supplementary Services tests', function () {
2697
3088
  jest.spyOn(global, 'clearTimeout');
2698
3089
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2699
3090
  call['held'] = false;
2700
- _context50.next = 1;
3091
+ _context53.next = 1;
2701
3092
  return call.doHoldResume();
2702
3093
  case 1:
2703
- _context50.next = 2;
3094
+ _context53.next = 2;
2704
3095
  return (0, _testUtil.flushPromises)(2);
2705
3096
  case 2:
2706
3097
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2715,19 +3106,19 @@ describe('Supplementary Services tests', function () {
2715
3106
  call['handleIncomingRoapOffer']({}, dummyEvent);
2716
3107
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2717
3108
  roapEvent.data.type = 'ANSWER';
2718
- _context50.next = 3;
3109
+ _context53.next = 3;
2719
3110
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2720
3111
  case 3:
2721
3112
  jest.spyOn(webex, 'request').mockRejectedValue({
2722
3113
  statusCode: 403
2723
3114
  });
2724
3115
  roapEvent.data.type = 'OK';
2725
- _context50.next = 4;
3116
+ _context53.next = 4;
2726
3117
  return call['handleRoapEstablished']({}, dummyEvent);
2727
3118
  case 4:
2728
3119
  /* this is for coverage */
2729
3120
  call['callStateMachine'].state.value = 'S_CALL_HOLD';
2730
- _context50.next = 5;
3121
+ _context53.next = 5;
2731
3122
  return call['handleRoapEstablished']({}, dummyEvent);
2732
3123
  case 5:
2733
3124
  expect(call.isHeld()).toStrictEqual(false);
@@ -2739,14 +3130,14 @@ describe('Supplementary Services tests', function () {
2739
3130
  });
2740
3131
  case 6:
2741
3132
  case "end":
2742
- return _context50.stop();
3133
+ return _context53.stop();
2743
3134
  }
2744
- }, _callee50);
3135
+ }, _callee53);
2745
3136
  })));
2746
- it('Handle failure Call resume case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
3137
+ it('Handle failure Call resume case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
2747
3138
  var responsePayload, warnSpy, roapEvent;
2748
- return _regenerator.default.wrap(function (_context51) {
2749
- while (1) switch (_context51.prev = _context51.next) {
3139
+ return _regenerator.default.wrap(function (_context54) {
3140
+ while (1) switch (_context54.prev = _context54.next) {
2750
3141
  case 0:
2751
3142
  responsePayload = {
2752
3143
  statusCode: 200,
@@ -2757,10 +3148,10 @@ describe('Supplementary Services tests', function () {
2757
3148
  jest.spyOn(global, 'clearTimeout');
2758
3149
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2759
3150
  call['held'] = true;
2760
- _context51.next = 1;
3151
+ _context54.next = 1;
2761
3152
  return call.doHoldResume();
2762
3153
  case 1:
2763
- _context51.next = 2;
3154
+ _context54.next = 2;
2764
3155
  return (0, _testUtil.flushPromises)(2);
2765
3156
  case 2:
2766
3157
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2775,14 +3166,14 @@ describe('Supplementary Services tests', function () {
2775
3166
  call['handleIncomingRoapOffer']({}, dummyEvent);
2776
3167
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2777
3168
  roapEvent.data.type = 'ANSWER';
2778
- _context51.next = 3;
3169
+ _context54.next = 3;
2779
3170
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2780
3171
  case 3:
2781
3172
  jest.spyOn(webex, 'request').mockRejectedValue({
2782
3173
  statusCode: 403
2783
3174
  });
2784
3175
  roapEvent.data.type = 'OK';
2785
- _context51.next = 4;
3176
+ _context54.next = 4;
2786
3177
  return call['handleRoapEstablished']({}, dummyEvent);
2787
3178
  case 4:
2788
3179
  expect(call.isHeld()).toStrictEqual(true);
@@ -2794,14 +3185,14 @@ describe('Supplementary Services tests', function () {
2794
3185
  });
2795
3186
  case 5:
2796
3187
  case "end":
2797
- return _context51.stop();
3188
+ return _context54.stop();
2798
3189
  }
2799
- }, _callee51);
3190
+ }, _callee54);
2800
3191
  })));
2801
- it('Handle Call hold case where successful Held response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
3192
+ it('Handle Call hold case where successful Held response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
2802
3193
  var responsePayload, roapEvent;
2803
- return _regenerator.default.wrap(function (_context53) {
2804
- while (1) switch (_context53.prev = _context53.next) {
3194
+ return _regenerator.default.wrap(function (_context56) {
3195
+ while (1) switch (_context56.prev = _context56.next) {
2805
3196
  case 0:
2806
3197
  expect.assertions(5);
2807
3198
  responsePayload = {
@@ -2811,25 +3202,25 @@ describe('Supplementary Services tests', function () {
2811
3202
  jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
2812
3203
  call['held'] = false;
2813
3204
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2814
- var _ref53 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52(errObj) {
2815
- return _regenerator.default.wrap(function (_context52) {
2816
- while (1) switch (_context52.prev = _context52.next) {
3205
+ var _ref64 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55(errObj) {
3206
+ return _regenerator.default.wrap(function (_context55) {
3207
+ while (1) switch (_context55.prev = _context55.next) {
2817
3208
  case 0:
2818
3209
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
2819
3210
  expect(errObj.message).toStrictEqual('An error occurred while placing the call on hold. Wait a moment and try again.');
2820
3211
  case 1:
2821
3212
  case "end":
2822
- return _context52.stop();
3213
+ return _context55.stop();
2823
3214
  }
2824
- }, _callee52);
3215
+ }, _callee55);
2825
3216
  }));
2826
3217
  return function (_x5) {
2827
- return _ref53.apply(this, arguments);
3218
+ return _ref64.apply(this, arguments);
2828
3219
  };
2829
3220
  }());
2830
3221
  jest.runAllTimers();
2831
3222
  call.doHoldResume();
2832
- _context53.next = 1;
3223
+ _context56.next = 1;
2833
3224
  return (0, _testUtil.flushPromises)(2);
2834
3225
  case 1:
2835
3226
  /* At this point, the Call State should be S_CALL_HOLD
@@ -2842,11 +3233,11 @@ describe('Supplementary Services tests', function () {
2842
3233
  call['handleIncomingRoapOffer']({}, dummyEvent);
2843
3234
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2844
3235
  roapEvent.data.type = 'ANSWER';
2845
- _context53.next = 2;
3236
+ _context56.next = 2;
2846
3237
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2847
3238
  case 2:
2848
3239
  roapEvent.data.type = 'OK';
2849
- _context53.next = 3;
3240
+ _context56.next = 3;
2850
3241
  return call['handleRoapEstablished']({}, dummyEvent);
2851
3242
  case 3:
2852
3243
  /* Advancing timer by 12 seconds so that it gets timed out */
@@ -2858,14 +3249,14 @@ describe('Supplementary Services tests', function () {
2858
3249
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2859
3250
  case 4:
2860
3251
  case "end":
2861
- return _context53.stop();
3252
+ return _context56.stop();
2862
3253
  }
2863
- }, _callee53);
3254
+ }, _callee56);
2864
3255
  })));
2865
- it('Handle successful Call Resume case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55() {
3256
+ it('Handle successful Call Resume case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
2866
3257
  var responsePayload, warnSpy, roapEvent;
2867
- return _regenerator.default.wrap(function (_context55) {
2868
- while (1) switch (_context55.prev = _context55.next) {
3258
+ return _regenerator.default.wrap(function (_context58) {
3259
+ while (1) switch (_context58.prev = _context58.next) {
2869
3260
  case 0:
2870
3261
  expect.assertions(7);
2871
3262
  responsePayload = {
@@ -2878,25 +3269,25 @@ describe('Supplementary Services tests', function () {
2878
3269
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2879
3270
  call['held'] = true;
2880
3271
  call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
2881
- var _ref55 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54(correlationId) {
2882
- return _regenerator.default.wrap(function (_context54) {
2883
- while (1) switch (_context54.prev = _context54.next) {
3272
+ var _ref66 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57(correlationId) {
3273
+ return _regenerator.default.wrap(function (_context57) {
3274
+ while (1) switch (_context57.prev = _context57.next) {
2884
3275
  case 0:
2885
3276
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2886
3277
  case 1:
2887
3278
  case "end":
2888
- return _context54.stop();
3279
+ return _context57.stop();
2889
3280
  }
2890
- }, _callee54);
3281
+ }, _callee57);
2891
3282
  }));
2892
3283
  return function (_x6) {
2893
- return _ref55.apply(this, arguments);
3284
+ return _ref66.apply(this, arguments);
2894
3285
  };
2895
3286
  }());
2896
- _context55.next = 1;
3287
+ _context58.next = 1;
2897
3288
  return call.doHoldResume();
2898
3289
  case 1:
2899
- _context55.next = 2;
3290
+ _context58.next = 2;
2900
3291
  return (0, _testUtil.flushPromises)(2);
2901
3292
  case 2:
2902
3293
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2912,11 +3303,11 @@ describe('Supplementary Services tests', function () {
2912
3303
  call['handleIncomingRoapOffer']({}, dummyEvent);
2913
3304
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2914
3305
  roapEvent.data.type = 'ANSWER';
2915
- _context55.next = 3;
3306
+ _context58.next = 3;
2916
3307
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2917
3308
  case 3:
2918
3309
  roapEvent.data.type = 'OK';
2919
- _context55.next = 4;
3310
+ _context58.next = 4;
2920
3311
  return call['handleRoapEstablished']({}, dummyEvent);
2921
3312
  case 4:
2922
3313
  expect(clearTimeout).toHaveBeenCalledTimes(1);
@@ -2931,14 +3322,14 @@ describe('Supplementary Services tests', function () {
2931
3322
  });
2932
3323
  case 5:
2933
3324
  case "end":
2934
- return _context55.stop();
3325
+ return _context58.stop();
2935
3326
  }
2936
- }, _callee55);
3327
+ }, _callee58);
2937
3328
  })));
2938
- it('Handle successful Call Resume case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57() {
3329
+ it('Handle successful Call Resume case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60() {
2939
3330
  var responsePayload, warnSpy, roapEvent;
2940
- return _regenerator.default.wrap(function (_context57) {
2941
- while (1) switch (_context57.prev = _context57.next) {
3331
+ return _regenerator.default.wrap(function (_context60) {
3332
+ while (1) switch (_context60.prev = _context60.next) {
2942
3333
  case 0:
2943
3334
  expect.assertions(7);
2944
3335
  responsePayload = {
@@ -2951,26 +3342,26 @@ describe('Supplementary Services tests', function () {
2951
3342
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2952
3343
  call['held'] = true;
2953
3344
  call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
2954
- var _ref57 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56(correlationId) {
2955
- return _regenerator.default.wrap(function (_context56) {
2956
- while (1) switch (_context56.prev = _context56.next) {
3345
+ var _ref68 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59(correlationId) {
3346
+ return _regenerator.default.wrap(function (_context59) {
3347
+ while (1) switch (_context59.prev = _context59.next) {
2957
3348
  case 0:
2958
3349
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2959
3350
  case 1:
2960
3351
  case "end":
2961
- return _context56.stop();
3352
+ return _context59.stop();
2962
3353
  }
2963
- }, _callee56);
3354
+ }, _callee59);
2964
3355
  }));
2965
3356
  return function (_x7) {
2966
- return _ref57.apply(this, arguments);
3357
+ return _ref68.apply(this, arguments);
2967
3358
  };
2968
3359
  }());
2969
3360
  call.doHoldResume();
2970
- _context57.next = 1;
3361
+ _context60.next = 1;
2971
3362
  return _promise.default.resolve();
2972
3363
  case 1:
2973
- _context57.next = 2;
3364
+ _context60.next = 2;
2974
3365
  return _promise.default.resolve();
2975
3366
  case 2:
2976
3367
  expect(setTimeout).not.toHaveBeenCalled();
@@ -2986,11 +3377,11 @@ describe('Supplementary Services tests', function () {
2986
3377
  call['handleIncomingRoapOffer']({}, dummyEvent);
2987
3378
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2988
3379
  roapEvent.data.type = 'ANSWER';
2989
- _context57.next = 3;
3380
+ _context60.next = 3;
2990
3381
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2991
3382
  case 3:
2992
3383
  roapEvent.data.type = 'OK';
2993
- _context57.next = 4;
3384
+ _context60.next = 4;
2994
3385
  return call['handleRoapEstablished']({}, dummyEvent);
2995
3386
  case 4:
2996
3387
  expect(clearTimeout).not.toHaveBeenCalled();
@@ -3005,14 +3396,14 @@ describe('Supplementary Services tests', function () {
3005
3396
  });
3006
3397
  case 5:
3007
3398
  case "end":
3008
- return _context57.stop();
3399
+ return _context60.stop();
3009
3400
  }
3010
- }, _callee57);
3401
+ }, _callee60);
3011
3402
  })));
3012
- it('Handle failure Call Resume case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59() {
3403
+ it('Handle failure Call Resume case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62() {
3013
3404
  var responsePayload;
3014
- return _regenerator.default.wrap(function (_context59) {
3015
- while (1) switch (_context59.prev = _context59.next) {
3405
+ return _regenerator.default.wrap(function (_context62) {
3406
+ while (1) switch (_context62.prev = _context62.next) {
3016
3407
  case 0:
3017
3408
  expect.assertions(4);
3018
3409
  responsePayload = {
@@ -3022,26 +3413,26 @@ describe('Supplementary Services tests', function () {
3022
3413
  jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
3023
3414
  call['held'] = true;
3024
3415
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
3025
- var _ref59 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58(errObj) {
3026
- return _regenerator.default.wrap(function (_context58) {
3027
- while (1) switch (_context58.prev = _context58.next) {
3416
+ var _ref70 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61(errObj) {
3417
+ return _regenerator.default.wrap(function (_context61) {
3418
+ while (1) switch (_context61.prev = _context61.next) {
3028
3419
  case 0:
3029
3420
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
3030
3421
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
3031
3422
  case 1:
3032
3423
  case "end":
3033
- return _context58.stop();
3424
+ return _context61.stop();
3034
3425
  }
3035
- }, _callee58);
3426
+ }, _callee61);
3036
3427
  }));
3037
3428
  return function (_x8) {
3038
- return _ref59.apply(this, arguments);
3429
+ return _ref70.apply(this, arguments);
3039
3430
  };
3040
3431
  }());
3041
- _context59.next = 1;
3432
+ _context62.next = 1;
3042
3433
  return call.doHoldResume();
3043
3434
  case 1:
3044
- _context59.next = 2;
3435
+ _context62.next = 2;
3045
3436
  return (0, _testUtil.flushPromises)(2);
3046
3437
  case 2:
3047
3438
  expect(call.isHeld()).toStrictEqual(true);
@@ -3052,14 +3443,14 @@ describe('Supplementary Services tests', function () {
3052
3443
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
3053
3444
  case 3:
3054
3445
  case "end":
3055
- return _context59.stop();
3446
+ return _context62.stop();
3056
3447
  }
3057
- }, _callee59);
3448
+ }, _callee62);
3058
3449
  })));
3059
- it('Handle failure Call Resume case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61() {
3450
+ it('Handle failure Call Resume case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
3060
3451
  var responsePayload, rejectPayload, roapEvent;
3061
- return _regenerator.default.wrap(function (_context61) {
3062
- while (1) switch (_context61.prev = _context61.next) {
3452
+ return _regenerator.default.wrap(function (_context64) {
3453
+ while (1) switch (_context64.prev = _context64.next) {
3063
3454
  case 0:
3064
3455
  expect.assertions(5);
3065
3456
  responsePayload = {
@@ -3073,24 +3464,24 @@ describe('Supplementary Services tests', function () {
3073
3464
  jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
3074
3465
  call['held'] = true;
3075
3466
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
3076
- var _ref61 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60(errObj) {
3077
- return _regenerator.default.wrap(function (_context60) {
3078
- while (1) switch (_context60.prev = _context60.next) {
3467
+ var _ref72 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63(errObj) {
3468
+ return _regenerator.default.wrap(function (_context63) {
3469
+ while (1) switch (_context63.prev = _context63.next) {
3079
3470
  case 0:
3080
3471
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
3081
3472
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
3082
3473
  case 1:
3083
3474
  case "end":
3084
- return _context60.stop();
3475
+ return _context63.stop();
3085
3476
  }
3086
- }, _callee60);
3477
+ }, _callee63);
3087
3478
  }));
3088
3479
  return function (_x9) {
3089
- return _ref61.apply(this, arguments);
3480
+ return _ref72.apply(this, arguments);
3090
3481
  };
3091
3482
  }());
3092
3483
  call.doHoldResume();
3093
- _context61.next = 1;
3484
+ _context64.next = 1;
3094
3485
  return (0, _testUtil.flushPromises)(2);
3095
3486
  case 1:
3096
3487
  /* At this point , the Call State should transition to S_CALL_ESTABLISHED
@@ -3101,7 +3492,7 @@ describe('Supplementary Services tests', function () {
3101
3492
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
3102
3493
  /* We are intentionally failing the ROAP ANSWER */
3103
3494
  roapEvent.data.type = 'ANSWER';
3104
- _context61.next = 2;
3495
+ _context64.next = 2;
3105
3496
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
3106
3497
  case 2:
3107
3498
  expect(call.isHeld()).toStrictEqual(true);
@@ -3109,14 +3500,14 @@ describe('Supplementary Services tests', function () {
3109
3500
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
3110
3501
  case 3:
3111
3502
  case "end":
3112
- return _context61.stop();
3503
+ return _context64.stop();
3113
3504
  }
3114
- }, _callee61);
3505
+ }, _callee64);
3115
3506
  })));
3116
- it('Handle Call resume case where successful response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63() {
3507
+ it('Handle Call resume case where successful response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee66() {
3117
3508
  var responsePayload, roapEvent;
3118
- return _regenerator.default.wrap(function (_context63) {
3119
- while (1) switch (_context63.prev = _context63.next) {
3509
+ return _regenerator.default.wrap(function (_context66) {
3510
+ while (1) switch (_context66.prev = _context66.next) {
3120
3511
  case 0:
3121
3512
  expect.assertions(5);
3122
3513
  responsePayload = {
@@ -3126,24 +3517,24 @@ describe('Supplementary Services tests', function () {
3126
3517
  jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
3127
3518
  call['held'] = true;
3128
3519
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
3129
- var _ref63 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62(errObj) {
3130
- return _regenerator.default.wrap(function (_context62) {
3131
- while (1) switch (_context62.prev = _context62.next) {
3520
+ var _ref74 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee65(errObj) {
3521
+ return _regenerator.default.wrap(function (_context65) {
3522
+ while (1) switch (_context65.prev = _context65.next) {
3132
3523
  case 0:
3133
3524
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
3134
3525
  expect(errObj.message).toStrictEqual('An error occurred while resuming the call. Wait a moment and try again.');
3135
3526
  case 1:
3136
3527
  case "end":
3137
- return _context62.stop();
3528
+ return _context65.stop();
3138
3529
  }
3139
- }, _callee62);
3530
+ }, _callee65);
3140
3531
  }));
3141
3532
  return function (_x0) {
3142
- return _ref63.apply(this, arguments);
3533
+ return _ref74.apply(this, arguments);
3143
3534
  };
3144
3535
  }());
3145
3536
  call.doHoldResume();
3146
- _context63.next = 1;
3537
+ _context66.next = 1;
3147
3538
  return (0, _testUtil.flushPromises)(2);
3148
3539
  case 1:
3149
3540
  /* At this point ,the Call State should be S_CALL_RESUME
@@ -3156,11 +3547,11 @@ describe('Supplementary Services tests', function () {
3156
3547
  call['handleIncomingRoapOffer']({}, dummyEvent);
3157
3548
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
3158
3549
  roapEvent.data.type = 'ANSWER';
3159
- _context63.next = 2;
3550
+ _context66.next = 2;
3160
3551
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
3161
3552
  case 2:
3162
3553
  roapEvent.data.type = 'OK';
3163
- _context63.next = 3;
3554
+ _context66.next = 3;
3164
3555
  return call['handleRoapEstablished']({}, dummyEvent);
3165
3556
  case 3:
3166
3557
  /* Advancing timer by 12 seconds so that it gets timed out */
@@ -3170,9 +3561,9 @@ describe('Supplementary Services tests', function () {
3170
3561
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
3171
3562
  case 4:
3172
3563
  case "end":
3173
- return _context63.stop();
3564
+ return _context66.stop();
3174
3565
  }
3175
- }, _callee63);
3566
+ }, _callee66);
3176
3567
  })));
3177
3568
  });
3178
3569
  describe('Call transfer tests', function () {
@@ -3205,10 +3596,10 @@ describe('Supplementary Services tests', function () {
3205
3596
  secondCall.removeAllListeners(_types2.CALL_EVENT_KEYS.CALL_ERROR);
3206
3597
  secondCall['held'] = false;
3207
3598
  });
3208
- it('Handle successful consult transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee66() {
3599
+ it('Handle successful consult transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee69() {
3209
3600
  var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
3210
- return _regenerator.default.wrap(function (_context66) {
3211
- while (1) switch (_context66.prev = _context66.next) {
3601
+ return _regenerator.default.wrap(function (_context69) {
3602
+ while (1) switch (_context69.prev = _context69.next) {
3212
3603
  case 0:
3213
3604
  expect.assertions(12); // Updated to match actual assertion count
3214
3605
  responsePayload = {
@@ -3220,41 +3611,41 @@ describe('Supplementary Services tests', function () {
3220
3611
  infoSpy = jest.spyOn(_Logger.default, 'info');
3221
3612
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3222
3613
  call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3223
- var _ref65 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64(correlationId) {
3224
- return _regenerator.default.wrap(function (_context64) {
3225
- while (1) switch (_context64.prev = _context64.next) {
3614
+ var _ref76 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee67(correlationId) {
3615
+ return _regenerator.default.wrap(function (_context67) {
3616
+ while (1) switch (_context67.prev = _context67.next) {
3226
3617
  case 0:
3227
3618
  expect(correlationId).toStrictEqual(call.getCorrelationId());
3228
3619
  case 1:
3229
3620
  case "end":
3230
- return _context64.stop();
3621
+ return _context67.stop();
3231
3622
  }
3232
- }, _callee64);
3623
+ }, _callee67);
3233
3624
  }));
3234
3625
  return function (_x1) {
3235
- return _ref65.apply(this, arguments);
3626
+ return _ref76.apply(this, arguments);
3236
3627
  };
3237
3628
  }());
3238
3629
  secondCall.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3239
- var _ref66 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee65(correlationId) {
3240
- return _regenerator.default.wrap(function (_context65) {
3241
- while (1) switch (_context65.prev = _context65.next) {
3630
+ var _ref77 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee68(correlationId) {
3631
+ return _regenerator.default.wrap(function (_context68) {
3632
+ while (1) switch (_context68.prev = _context68.next) {
3242
3633
  case 0:
3243
3634
  expect(correlationId).toStrictEqual(secondCall.getCorrelationId());
3244
3635
  case 1:
3245
3636
  case "end":
3246
- return _context65.stop();
3637
+ return _context68.stop();
3247
3638
  }
3248
- }, _callee65);
3639
+ }, _callee68);
3249
3640
  }));
3250
3641
  return function (_x10) {
3251
- return _ref66.apply(this, arguments);
3642
+ return _ref77.apply(this, arguments);
3252
3643
  };
3253
3644
  }());
3254
- _context66.next = 1;
3645
+ _context69.next = 1;
3255
3646
  return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
3256
3647
  case 1:
3257
- _context66.next = 2;
3648
+ _context69.next = 2;
3258
3649
  return (0, _testUtil.flushPromises)(2);
3259
3650
  case 2:
3260
3651
  expect(requestSpy).toBeCalled();
@@ -3277,14 +3668,14 @@ describe('Supplementary Services tests', function () {
3277
3668
  expect(warnSpy).not.toHaveBeenCalledWith("Consult Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
3278
3669
  case 3:
3279
3670
  case "end":
3280
- return _context66.stop();
3671
+ return _context69.stop();
3281
3672
  }
3282
- }, _callee66);
3673
+ }, _callee69);
3283
3674
  })));
3284
- it('Handle successful blind transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee68() {
3675
+ it('Handle successful blind transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee71() {
3285
3676
  var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
3286
- return _regenerator.default.wrap(function (_context68) {
3287
- while (1) switch (_context68.prev = _context68.next) {
3677
+ return _regenerator.default.wrap(function (_context71) {
3678
+ while (1) switch (_context71.prev = _context71.next) {
3288
3679
  case 0:
3289
3680
  expect.assertions(10); // Updated to match actual assertion count
3290
3681
  responsePayload = {
@@ -3296,25 +3687,25 @@ describe('Supplementary Services tests', function () {
3296
3687
  infoSpy = jest.spyOn(_Logger.default, 'info');
3297
3688
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3298
3689
  call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3299
- var _ref68 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee67(correlationId) {
3300
- return _regenerator.default.wrap(function (_context67) {
3301
- while (1) switch (_context67.prev = _context67.next) {
3690
+ var _ref79 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee70(correlationId) {
3691
+ return _regenerator.default.wrap(function (_context70) {
3692
+ while (1) switch (_context70.prev = _context70.next) {
3302
3693
  case 0:
3303
3694
  expect(correlationId).toStrictEqual(call.getCorrelationId());
3304
3695
  case 1:
3305
3696
  case "end":
3306
- return _context67.stop();
3697
+ return _context70.stop();
3307
3698
  }
3308
- }, _callee67);
3699
+ }, _callee70);
3309
3700
  }));
3310
3701
  return function (_x11) {
3311
- return _ref68.apply(this, arguments);
3702
+ return _ref79.apply(this, arguments);
3312
3703
  };
3313
3704
  }());
3314
- _context68.next = 1;
3705
+ _context71.next = 1;
3315
3706
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
3316
3707
  case 1:
3317
- _context68.next = 2;
3708
+ _context71.next = 2;
3318
3709
  return (0, _testUtil.flushPromises)(2);
3319
3710
  case 2:
3320
3711
  expect(requestSpy).toBeCalled();
@@ -3333,14 +3724,14 @@ describe('Supplementary Services tests', function () {
3333
3724
  expect(warnSpy).not.toHaveBeenCalledWith("Blind Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
3334
3725
  case 3:
3335
3726
  case "end":
3336
- return _context68.stop();
3727
+ return _context71.stop();
3337
3728
  }
3338
- }, _callee68);
3729
+ }, _callee71);
3339
3730
  })));
3340
- it('Handle unsuccessful blind transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee69() {
3731
+ it('Handle unsuccessful blind transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee72() {
3341
3732
  var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
3342
- return _regenerator.default.wrap(function (_context69) {
3343
- while (1) switch (_context69.prev = _context69.next) {
3733
+ return _regenerator.default.wrap(function (_context72) {
3734
+ while (1) switch (_context72.prev = _context72.next) {
3344
3735
  case 0:
3345
3736
  responsePayload = {
3346
3737
  statusCode: 403,
@@ -3351,10 +3742,10 @@ describe('Supplementary Services tests', function () {
3351
3742
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3352
3743
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3353
3744
  call['broadworksCorrelationInfo'] = 'dummy-broadworks-correlation-info';
3354
- _context69.next = 1;
3745
+ _context72.next = 1;
3355
3746
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
3356
3747
  case 1:
3357
- _context69.next = 2;
3748
+ _context72.next = 2;
3358
3749
  return (0, _testUtil.flushPromises)(1);
3359
3750
  case 2:
3360
3751
  expect(requestSpy).toBeCalled();
@@ -3375,14 +3766,14 @@ describe('Supplementary Services tests', function () {
3375
3766
  expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.BLIND, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
3376
3767
  case 3:
3377
3768
  case "end":
3378
- return _context69.stop();
3769
+ return _context72.stop();
3379
3770
  }
3380
- }, _callee69);
3771
+ }, _callee72);
3381
3772
  })));
3382
- it('Handle unsuccessful consult transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee70() {
3773
+ it('Handle unsuccessful consult transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee73() {
3383
3774
  var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
3384
- return _regenerator.default.wrap(function (_context70) {
3385
- while (1) switch (_context70.prev = _context70.next) {
3775
+ return _regenerator.default.wrap(function (_context73) {
3776
+ while (1) switch (_context73.prev = _context73.next) {
3386
3777
  case 0:
3387
3778
  responsePayload = {
3388
3779
  statusCode: 403,
@@ -3392,10 +3783,10 @@ describe('Supplementary Services tests', function () {
3392
3783
  requestSpy = jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
3393
3784
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3394
3785
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3395
- _context70.next = 1;
3786
+ _context73.next = 1;
3396
3787
  return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
3397
3788
  case 1:
3398
- _context70.next = 2;
3789
+ _context73.next = 2;
3399
3790
  return (0, _testUtil.flushPromises)(2);
3400
3791
  case 2:
3401
3792
  expect(requestSpy).toBeCalled();
@@ -3416,18 +3807,18 @@ describe('Supplementary Services tests', function () {
3416
3807
  expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.CONSULT, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
3417
3808
  case 3:
3418
3809
  case "end":
3419
- return _context70.stop();
3810
+ return _context73.stop();
3420
3811
  }
3421
- }, _callee70);
3812
+ }, _callee73);
3422
3813
  })));
3423
- it('Handle blind transfer with undefined transferTarget', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee71() {
3814
+ it('Handle blind transfer with undefined transferTarget', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee74() {
3424
3815
  var requestSpy, warnSpy;
3425
- return _regenerator.default.wrap(function (_context71) {
3426
- while (1) switch (_context71.prev = _context71.next) {
3816
+ return _regenerator.default.wrap(function (_context74) {
3817
+ while (1) switch (_context74.prev = _context74.next) {
3427
3818
  case 0:
3428
3819
  requestSpy = jest.spyOn(webex, 'request');
3429
3820
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3430
- _context71.next = 1;
3821
+ _context74.next = 1;
3431
3822
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, undefined);
3432
3823
  case 1:
3433
3824
  /* We should be in CALL_ESTABLISHED state */
@@ -3439,18 +3830,18 @@ describe('Supplementary Services tests', function () {
3439
3830
  expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
3440
3831
  case 2:
3441
3832
  case "end":
3442
- return _context71.stop();
3833
+ return _context74.stop();
3443
3834
  }
3444
- }, _callee71);
3835
+ }, _callee74);
3445
3836
  })));
3446
- it('Handle consult transfer with undefined transferCallId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee72() {
3837
+ it('Handle consult transfer with undefined transferCallId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee75() {
3447
3838
  var requestSpy, warnSpy;
3448
- return _regenerator.default.wrap(function (_context72) {
3449
- while (1) switch (_context72.prev = _context72.next) {
3839
+ return _regenerator.default.wrap(function (_context75) {
3840
+ while (1) switch (_context75.prev = _context75.next) {
3450
3841
  case 0:
3451
3842
  requestSpy = jest.spyOn(webex, 'request');
3452
3843
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3453
- _context72.next = 1;
3844
+ _context75.next = 1;
3454
3845
  return call.completeTransfer(_types5.TransferType.CONSULT, undefined, undefined);
3455
3846
  case 1:
3456
3847
  /* We should be in CALL_ESTABLISHED state */
@@ -3462,9 +3853,9 @@ describe('Supplementary Services tests', function () {
3462
3853
  expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
3463
3854
  case 2:
3464
3855
  case "end":
3465
- return _context72.stop();
3856
+ return _context75.stop();
3466
3857
  }
3467
- }, _callee72);
3858
+ }, _callee75);
3468
3859
  })));
3469
3860
  });
3470
3861
  });