@webex/calling 3.10.0-next.1 → 3.10.0-next.11

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 (61) hide show
  1. package/dist/CallHistory/CallHistory.js +26 -20
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +109 -0
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallSettings/WxCallBackendConnector.js +2 -1
  6. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  7. package/dist/CallingClient/CallingClient.js +160 -205
  8. package/dist/CallingClient/CallingClient.js.map +1 -1
  9. package/dist/CallingClient/CallingClient.test.js +152 -290
  10. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  11. package/dist/CallingClient/calling/call.js +61 -43
  12. package/dist/CallingClient/calling/call.js.map +1 -1
  13. package/dist/CallingClient/calling/call.test.js +594 -361
  14. package/dist/CallingClient/calling/call.test.js.map +1 -1
  15. package/dist/CallingClient/constants.js +3 -1
  16. package/dist/CallingClient/constants.js.map +1 -1
  17. package/dist/Contacts/ContactsClient.js +8 -5
  18. package/dist/Contacts/ContactsClient.js.map +1 -1
  19. package/dist/Events/impl/index.js +1 -2
  20. package/dist/Events/impl/index.js.map +1 -1
  21. package/dist/SDKConnector/types.js.map +1 -1
  22. package/dist/Voicemail/BroadworksBackendConnector.js +14 -12
  23. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  24. package/dist/Voicemail/UcmBackendConnector.js +2 -1
  25. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  26. package/dist/common/Utils.js +68 -39
  27. package/dist/common/Utils.js.map +1 -1
  28. package/dist/common/Utils.test.js +392 -143
  29. package/dist/common/Utils.test.js.map +1 -1
  30. package/dist/common/testUtil.js +2 -1
  31. package/dist/common/testUtil.js.map +1 -1
  32. package/dist/module/CallHistory/CallHistory.js +7 -3
  33. package/dist/module/CallSettings/WxCallBackendConnector.js +3 -1
  34. package/dist/module/CallingClient/CallingClient.js +83 -121
  35. package/dist/module/CallingClient/calling/call.js +35 -23
  36. package/dist/module/CallingClient/constants.js +1 -0
  37. package/dist/module/Contacts/ContactsClient.js +9 -5
  38. package/dist/module/Events/impl/index.js +1 -2
  39. package/dist/module/Voicemail/BroadworksBackendConnector.js +3 -1
  40. package/dist/module/Voicemail/UcmBackendConnector.js +2 -1
  41. package/dist/module/common/Utils.js +27 -3
  42. package/dist/module/common/testUtil.js +1 -0
  43. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  44. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  45. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  46. package/dist/types/CallingClient/calling/call.d.ts +2 -0
  47. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  48. package/dist/types/CallingClient/constants.d.ts +1 -0
  49. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  50. package/dist/types/Contacts/ContactsClient.d.ts +1 -0
  51. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  52. package/dist/types/Events/impl/index.d.ts.map +1 -1
  53. package/dist/types/SDKConnector/types.d.ts +10 -0
  54. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  55. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  56. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  57. package/dist/types/common/Utils.d.ts +1 -1
  58. package/dist/types/common/Utils.d.ts.map +1 -1
  59. package/dist/types/common/testUtil.d.ts +1 -0
  60. package/dist/types/common/testUtil.d.ts.map +1 -1
  61. package/package.json +4 -4
@@ -853,10 +853,43 @@ describe('State Machine handler tests', function () {
853
853
  }
854
854
  }, _callee13);
855
855
  })));
856
- it('session refresh failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
857
- var statusPayload, funcSpy;
856
+ it('session refresh 401 emits token error and ends the call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
857
+ var statusPayload, emitSpy, funcSpy;
858
858
  return _regenerator.default.wrap(function _callee14$(_context14) {
859
859
  while (1) switch (_context14.prev = _context14.next) {
860
+ case 0:
861
+ expect.assertions(4);
862
+ statusPayload = {
863
+ statusCode: 401
864
+ };
865
+ webex.request.mockReturnValue(statusPayload);
866
+ jest.spyOn(global, 'clearInterval');
867
+ emitSpy = jest.spyOn(call, 'emit');
868
+ call.on(_types2.CALL_EVENT_KEYS.CALL_ERROR, function (errObj) {
869
+ expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TOKEN_ERROR);
870
+ });
871
+ funcSpy = jest.spyOn(call, 'postStatus').mockRejectedValue(statusPayload);
872
+ call['handleCallEstablished']({});
873
+ jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
874
+ _context14.next = 11;
875
+ return _promise.default.resolve();
876
+ case 11:
877
+ _context14.next = 13;
878
+ return _promise.default.resolve();
879
+ case 13:
880
+ expect(clearInterval).toHaveBeenCalledTimes(1);
881
+ expect(funcSpy).toBeCalledTimes(1);
882
+ expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
883
+ case 16:
884
+ case "end":
885
+ return _context14.stop();
886
+ }
887
+ }, _callee14);
888
+ })));
889
+ it('session refresh failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
890
+ var statusPayload, funcSpy;
891
+ return _regenerator.default.wrap(function _callee15$(_context15) {
892
+ while (1) switch (_context15.prev = _context15.next) {
860
893
  case 0:
861
894
  expect.assertions(4);
862
895
  statusPayload = {
@@ -880,24 +913,134 @@ describe('State Machine handler tests', function () {
880
913
  /* This is to flush all the promises from the Promise queue so that
881
914
  * Jest.fakeTimers can advance time and also clear the promise Queue
882
915
  */
883
- _context14.next = 11;
916
+ _context15.next = 11;
884
917
  return _promise.default.resolve();
885
918
  case 11:
886
- _context14.next = 13;
919
+ _context15.next = 13;
887
920
  return _promise.default.resolve();
888
921
  case 13:
889
922
  expect(clearInterval).toHaveBeenCalledTimes(2); // check this
890
923
  expect(funcSpy).toBeCalledTimes(1);
891
924
  case 15:
892
925
  case "end":
893
- return _context14.stop();
926
+ return _context15.stop();
894
927
  }
895
- }, _callee14);
928
+ }, _callee15);
896
929
  })));
897
- it('state changes during successful incoming call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
930
+ it('session refresh 500 schedules retry via retry-after or default interval', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
931
+ var errorPayload, okPayload, sendEvtSpy, postStatusSpy;
932
+ return _regenerator.default.wrap(function _callee16$(_context16) {
933
+ while (1) switch (_context16.prev = _context16.next) {
934
+ case 0:
935
+ errorPayload = {
936
+ statusCode: 500,
937
+ headers: {
938
+ 'retry-after': 1
939
+ }
940
+ };
941
+ okPayload = {
942
+ statusCode: 200,
943
+ body: {}
944
+ };
945
+ sendEvtSpy = jest.spyOn(call, 'sendCallStateMachineEvt');
946
+ postStatusSpy = jest.spyOn(call, 'postStatus').mockRejectedValueOnce(errorPayload).mockResolvedValueOnce(okPayload);
947
+ if (call['sessionTimer'] === undefined) {
948
+ call['handleCallEstablished']({});
949
+ }
950
+ jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
951
+ _context16.next = 8;
952
+ return _promise.default.resolve();
953
+ case 8:
954
+ _context16.next = 10;
955
+ return _promise.default.resolve();
956
+ case 10:
957
+ expect(postStatusSpy).toHaveBeenCalledTimes(1);
958
+ expect(sendEvtSpy).toHaveBeenCalledWith({
959
+ type: 'E_CALL_ESTABLISHED'
960
+ });
961
+ case 12:
962
+ case "end":
963
+ return _context16.stop();
964
+ }
965
+ }, _callee16);
966
+ })));
967
+ it('keepalive ends after reaching max retry count', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
968
+ var resolvePromise, errorPayload, warnSpy, postStatusSpy;
969
+ return _regenerator.default.wrap(function _callee18$(_context18) {
970
+ while (1) switch (_context18.prev = _context18.next) {
971
+ case 0:
972
+ resolvePromise = /*#__PURE__*/function () {
973
+ var _ref18 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
974
+ return _regenerator.default.wrap(function _callee17$(_context17) {
975
+ while (1) switch (_context17.prev = _context17.next) {
976
+ case 0:
977
+ _context17.next = 2;
978
+ return _promise.default.resolve();
979
+ case 2:
980
+ _context17.next = 4;
981
+ return _promise.default.resolve();
982
+ case 4:
983
+ case "end":
984
+ return _context17.stop();
985
+ }
986
+ }, _callee17);
987
+ }));
988
+ return function resolvePromise() {
989
+ return _ref18.apply(this, arguments);
990
+ };
991
+ }();
992
+ errorPayload = {
993
+ statusCode: 500,
994
+ headers: {
995
+ 'retry-after': 1
996
+ }
997
+ };
998
+ jest.spyOn(global, 'clearInterval');
999
+ warnSpy = jest.spyOn(_Logger.default, 'warn');
1000
+ postStatusSpy = jest.spyOn(call, 'postStatus').mockRejectedValue(errorPayload); // Put the call in the S_CALL_ESTABLISHED state and set it as connected
1001
+ call['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
1002
+ call['connected'] = true;
1003
+
1004
+ // Call handleCallEstablished which will setup interval
1005
+ call['handleCallEstablished']({});
1006
+
1007
+ // Advance timer to trigger the first failure (uses DEFAULT_SESSION_TIMER)
1008
+ jest.advanceTimersByTime(_constants.DEFAULT_SESSION_TIMER);
1009
+ _context18.next = 11;
1010
+ return resolvePromise();
1011
+ case 11:
1012
+ // Now advance by 1 second for each of the 3 more retry attempts (retry-after: 1 second each)
1013
+ // Need to do this separately to allow state machine to process and create new intervals
1014
+ jest.advanceTimersByTime(1000);
1015
+ _context18.next = 14;
1016
+ return resolvePromise();
1017
+ case 14:
1018
+ jest.advanceTimersByTime(1000);
1019
+ _context18.next = 17;
1020
+ return resolvePromise();
1021
+ case 17:
1022
+ jest.advanceTimersByTime(1000);
1023
+ _context18.next = 20;
1024
+ return resolvePromise();
1025
+ case 20:
1026
+ // The error handler should detect we're at max retry count and stop
1027
+ expect(warnSpy).toHaveBeenCalledWith("Max call keepalive retry attempts reached for call: ".concat(call.getCorrelationId()), {
1028
+ file: 'call',
1029
+ method: 'handleCallEstablished'
1030
+ });
1031
+ expect(postStatusSpy).toHaveBeenCalledTimes(4);
1032
+ expect(call['callKeepaliveRetryCount']).toBe(0);
1033
+ expect(call['sessionTimer']).toBeUndefined();
1034
+ case 24:
1035
+ case "end":
1036
+ return _context18.stop();
1037
+ }
1038
+ }, _callee18);
1039
+ })));
1040
+ it('state changes during successful incoming call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
898
1041
  var statusPayload, dummyEvent, postMediaSpy, deleteSpy, dummyOkEvent;
899
- return _regenerator.default.wrap(function _callee15$(_context15) {
900
- while (1) switch (_context15.prev = _context15.next) {
1042
+ return _regenerator.default.wrap(function _callee19$(_context19) {
1043
+ while (1) switch (_context19.prev = _context19.next) {
901
1044
  case 0:
902
1045
  statusPayload = {
903
1046
  statusCode: 200,
@@ -953,14 +1096,14 @@ describe('State Machine handler tests', function () {
953
1096
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
954
1097
  case 27:
955
1098
  case "end":
956
- return _context15.stop();
1099
+ return _context19.stop();
957
1100
  }
958
- }, _callee15);
1101
+ }, _callee19);
959
1102
  })));
960
- it('state changes during unsuccessful incoming call due to no offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1103
+ it('state changes during unsuccessful incoming call due to no offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
961
1104
  var statusPayload, dummyEvent;
962
- return _regenerator.default.wrap(function _callee16$(_context16) {
963
- while (1) switch (_context16.prev = _context16.next) {
1105
+ return _regenerator.default.wrap(function _callee20$(_context20) {
1106
+ while (1) switch (_context20.prev = _context20.next) {
964
1107
  case 0:
965
1108
  call['direction'] = _types3.CallDirection.INBOUND;
966
1109
  statusPayload = {
@@ -978,7 +1121,7 @@ describe('State Machine handler tests', function () {
978
1121
  webex.request.mockReturnValue(statusPayload);
979
1122
  call.sendCallStateMachineEvt(dummyEvent);
980
1123
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
981
- _context16.next = 8;
1124
+ _context20.next = 8;
982
1125
  return call['handleOutgoingCallConnect']({
983
1126
  type: 'E_SEND_CALL_CONNECT'
984
1127
  });
@@ -992,14 +1135,14 @@ describe('State Machine handler tests', function () {
992
1135
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
993
1136
  case 12:
994
1137
  case "end":
995
- return _context16.stop();
1138
+ return _context20.stop();
996
1139
  }
997
- }, _callee16);
1140
+ }, _callee20);
998
1141
  })));
999
- it('state changes during unsuccessful incoming call due error in call connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1142
+ it('state changes during unsuccessful incoming call due error in call connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1000
1143
  var warnSpy, errorSpy, stateMachineSpy, statusPayload, roapMessage;
1001
- return _regenerator.default.wrap(function _callee17$(_context17) {
1002
- while (1) switch (_context17.prev = _context17.next) {
1144
+ return _regenerator.default.wrap(function _callee21$(_context21) {
1145
+ while (1) switch (_context21.prev = _context21.next) {
1003
1146
  case 0:
1004
1147
  warnSpy = jest.spyOn(_Logger.default, 'warn');
1005
1148
  errorSpy = jest.spyOn(_Logger.default, 'error');
@@ -1026,7 +1169,7 @@ describe('State Machine handler tests', function () {
1026
1169
  webex.request.mockRejectedValueOnce({
1027
1170
  statusCode: 403
1028
1171
  }).mockResolvedValue(statusPayload);
1029
- _context17.next = 13;
1172
+ _context21.next = 13;
1030
1173
  return call['handleOutgoingCallConnect']({
1031
1174
  type: 'E_SEND_CALL_CONNECT'
1032
1175
  });
@@ -1037,14 +1180,14 @@ describe('State Machine handler tests', function () {
1037
1180
  expect(errorSpy).toBeCalledTimes(1);
1038
1181
  case 17:
1039
1182
  case "end":
1040
- return _context17.stop();
1183
+ return _context21.stop();
1041
1184
  }
1042
- }, _callee17);
1185
+ }, _callee21);
1043
1186
  })));
1044
- it('state changes during successful outgoing call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1187
+ it('state changes during successful outgoing call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1045
1188
  var statusPayload, dummyEvent, postMediaSpy, logSpy, dummyOkEvent;
1046
- return _regenerator.default.wrap(function _callee18$(_context18) {
1047
- while (1) switch (_context18.prev = _context18.next) {
1189
+ return _regenerator.default.wrap(function _callee22$(_context22) {
1190
+ while (1) switch (_context22.prev = _context22.next) {
1048
1191
  case 0:
1049
1192
  statusPayload = {
1050
1193
  statusCode: 200,
@@ -1120,14 +1263,14 @@ describe('State Machine handler tests', function () {
1120
1263
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
1121
1264
  case 42:
1122
1265
  case "end":
1123
- return _context18.stop();
1266
+ return _context22.stop();
1124
1267
  }
1125
- }, _callee18);
1268
+ }, _callee22);
1126
1269
  })));
1127
- 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 _callee19() {
1270
+ 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 _callee23() {
1128
1271
  var statusPayload, dummySetupEvent, dummyConnectEvent, dummyOfferEvent, dummyAnswerEvent, dummyOkEvent, postMediaSpy;
1129
- return _regenerator.default.wrap(function _callee19$(_context19) {
1130
- while (1) switch (_context19.prev = _context19.next) {
1272
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1273
+ while (1) switch (_context23.prev = _context23.next) {
1131
1274
  case 0:
1132
1275
  statusPayload = {
1133
1276
  statusCode: 200,
@@ -1195,14 +1338,14 @@ describe('State Machine handler tests', function () {
1195
1338
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_DISCONNECT');
1196
1339
  case 25:
1197
1340
  case "end":
1198
- return _context19.stop();
1341
+ return _context23.stop();
1199
1342
  }
1200
- }, _callee19);
1343
+ }, _callee23);
1201
1344
  })));
1202
- it('state changes during successful outgoing call with early media', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1345
+ it('state changes during successful outgoing call with early media', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1203
1346
  var statusPayload, dummyEvent;
1204
- return _regenerator.default.wrap(function _callee20$(_context20) {
1205
- while (1) switch (_context20.prev = _context20.next) {
1347
+ return _regenerator.default.wrap(function _callee24$(_context24) {
1348
+ while (1) switch (_context24.prev = _context24.next) {
1206
1349
  case 0:
1207
1350
  statusPayload = {
1208
1351
  statusCode: 200,
@@ -1241,14 +1384,14 @@ describe('State Machine handler tests', function () {
1241
1384
  expect(call['callStateMachine'].state.value).toBe('S_RECV_CALL_DISCONNECT');
1242
1385
  case 17:
1243
1386
  case "end":
1244
- return _context20.stop();
1387
+ return _context24.stop();
1245
1388
  }
1246
- }, _callee20);
1389
+ }, _callee24);
1247
1390
  })));
1248
- it('state changes during unsuccessful outgoing call due to error in call setup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1391
+ it('state changes during unsuccessful outgoing call due to error in call setup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1249
1392
  var statusPayload, dummyEvent, errorSpy;
1250
- return _regenerator.default.wrap(function _callee21$(_context21) {
1251
- while (1) switch (_context21.prev = _context21.next) {
1393
+ return _regenerator.default.wrap(function _callee25$(_context25) {
1394
+ while (1) switch (_context25.prev = _context25.next) {
1252
1395
  case 0:
1253
1396
  statusPayload = {
1254
1397
  statusCode: 403,
@@ -1265,7 +1408,7 @@ describe('State Machine handler tests', function () {
1265
1408
  webex.request.mockRejectedValueOnce(statusPayload);
1266
1409
  errorSpy = jest.spyOn(_Logger.default, 'error');
1267
1410
  call.sendCallStateMachineEvt(dummyEvent);
1268
- _context21.next = 7;
1411
+ _context25.next = 7;
1269
1412
  return (0, _testUtil.flushPromises)(3);
1270
1413
  case 7:
1271
1414
  expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
@@ -1276,14 +1419,14 @@ describe('State Machine handler tests', function () {
1276
1419
  });
1277
1420
  case 10:
1278
1421
  case "end":
1279
- return _context21.stop();
1422
+ return _context25.stop();
1280
1423
  }
1281
- }, _callee21);
1424
+ }, _callee25);
1282
1425
  })));
1283
- it('state changes during unsuccessful outgoing call due to error in media ok', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1426
+ it('state changes during unsuccessful outgoing call due to error in media ok', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1284
1427
  var statusPayload, dummyEvent, warnSpy;
1285
- return _regenerator.default.wrap(function _callee22$(_context22) {
1286
- while (1) switch (_context22.prev = _context22.next) {
1428
+ return _regenerator.default.wrap(function _callee26$(_context26) {
1429
+ while (1) switch (_context26.prev = _context26.next) {
1287
1430
  case 0:
1288
1431
  statusPayload = {
1289
1432
  statusCode: 403,
@@ -1302,33 +1445,33 @@ describe('State Machine handler tests', function () {
1302
1445
  webex.request.mockRejectedValue(statusPayload);
1303
1446
  warnSpy = jest.spyOn(_Logger.default, 'warn');
1304
1447
  jest.spyOn(Utils, 'uploadLogs').mockResolvedValue(undefined);
1305
- _context22.next = 10;
1448
+ _context26.next = 10;
1306
1449
  return call['handleRoapEstablished']({}, dummyEvent);
1307
1450
  case 10:
1308
- _context22.next = 12;
1451
+ _context26.next = 12;
1309
1452
  return (0, _testUtil.flushPromises)(2);
1310
1453
  case 12:
1311
1454
  expect(call.isConnected()).toBe(false);
1312
- expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_ERROR');
1313
- expect(call['callStateMachine'].state.value).toBe('S_UNKNOWN');
1455
+ expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_TEARDOWN');
1456
+ expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1314
1457
  expect(warnSpy).toHaveBeenCalledWith('Failed to process MediaOk request', {
1315
1458
  file: 'call',
1316
1459
  method: 'handleRoapEstablished'
1317
1460
  });
1318
- expect(uploadLogsSpy).toHaveBeenCalledWith({
1319
- correlationId: call.getCorrelationId(),
1320
- callId: call.getCallId()
1461
+ expect(warnSpy).toHaveBeenCalledWith('Call failed due to media issue', {
1462
+ file: 'call',
1463
+ method: 'handleRoapError'
1321
1464
  });
1322
1465
  case 17:
1323
1466
  case "end":
1324
- return _context22.stop();
1467
+ return _context26.stop();
1325
1468
  }
1326
- }, _callee22);
1469
+ }, _callee26);
1327
1470
  })));
1328
- it('state changes during unsuccessful outgoing call since no sdp in offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1471
+ it('state changes during unsuccessful outgoing call since no sdp in offer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1329
1472
  var statusPayload, dummyEvent;
1330
- return _regenerator.default.wrap(function _callee23$(_context23) {
1331
- while (1) switch (_context23.prev = _context23.next) {
1473
+ return _regenerator.default.wrap(function _callee27$(_context27) {
1474
+ while (1) switch (_context27.prev = _context27.next) {
1332
1475
  case 0:
1333
1476
  statusPayload = {
1334
1477
  statusCode: 403,
@@ -1351,14 +1494,14 @@ describe('State Machine handler tests', function () {
1351
1494
  expect(_testUtil.mediaConnection.initiateOffer).toBeCalledOnceWith();
1352
1495
  case 8:
1353
1496
  case "end":
1354
- return _context23.stop();
1497
+ return _context27.stop();
1355
1498
  }
1356
- }, _callee23);
1499
+ }, _callee27);
1357
1500
  })));
1358
- it('Outgoing Roap offer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1501
+ it('Outgoing Roap offer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1359
1502
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1360
- return _regenerator.default.wrap(function _callee24$(_context24) {
1361
- while (1) switch (_context24.prev = _context24.next) {
1503
+ return _regenerator.default.wrap(function _callee28$(_context28) {
1504
+ while (1) switch (_context28.prev = _context28.next) {
1362
1505
  case 0:
1363
1506
  statusPayload = {
1364
1507
  statusCode: 503,
@@ -1380,7 +1523,7 @@ describe('State Machine handler tests', function () {
1380
1523
  }
1381
1524
  };
1382
1525
  call['connected'] = true;
1383
- _context24.next = 8;
1526
+ _context28.next = 8;
1384
1527
  return call['handleOutgoingRoapOffer']({}, dummyEvent);
1385
1528
  case 8:
1386
1529
  jest.advanceTimersByTime(1005);
@@ -1392,14 +1535,14 @@ describe('State Machine handler tests', function () {
1392
1535
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1393
1536
  case 13:
1394
1537
  case "end":
1395
- return _context24.stop();
1538
+ return _context28.stop();
1396
1539
  }
1397
- }, _callee24);
1540
+ }, _callee28);
1398
1541
  })));
1399
- it('Outgoing Roap offer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1542
+ it('Outgoing Roap offer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1400
1543
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1401
- return _regenerator.default.wrap(function _callee25$(_context25) {
1402
- while (1) switch (_context25.prev = _context25.next) {
1544
+ return _regenerator.default.wrap(function _callee29$(_context29) {
1545
+ while (1) switch (_context29.prev = _context29.next) {
1403
1546
  case 0:
1404
1547
  statusPayload = {
1405
1548
  statusCode: 503,
@@ -1421,7 +1564,7 @@ describe('State Machine handler tests', function () {
1421
1564
  }
1422
1565
  };
1423
1566
  call['connected'] = false;
1424
- _context25.next = 8;
1567
+ _context29.next = 8;
1425
1568
  return call['handleOutgoingRoapOffer']({}, dummyEvent);
1426
1569
  case 8:
1427
1570
  jest.advanceTimersByTime(1005);
@@ -1432,14 +1575,14 @@ describe('State Machine handler tests', function () {
1432
1575
  expect(stateMachineSpy).not.toBeCalled();
1433
1576
  case 12:
1434
1577
  case "end":
1435
- return _context25.stop();
1578
+ return _context29.stop();
1436
1579
  }
1437
- }, _callee25);
1580
+ }, _callee29);
1438
1581
  })));
1439
- it('Outgoing Roap Answer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1582
+ it('Outgoing Roap Answer retry-after error case during midcall', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1440
1583
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1441
- return _regenerator.default.wrap(function _callee26$(_context26) {
1442
- while (1) switch (_context26.prev = _context26.next) {
1584
+ return _regenerator.default.wrap(function _callee30$(_context30) {
1585
+ while (1) switch (_context30.prev = _context30.next) {
1443
1586
  case 0:
1444
1587
  statusPayload = {
1445
1588
  statusCode: 503,
@@ -1461,7 +1604,7 @@ describe('State Machine handler tests', function () {
1461
1604
  };
1462
1605
  call['connected'] = true;
1463
1606
  call['mediaStateMachine'].state.value = 'S_RECV_ROAP_OFFER';
1464
- _context26.next = 9;
1607
+ _context30.next = 9;
1465
1608
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
1466
1609
  case 9:
1467
1610
  jest.advanceTimersByTime(1005);
@@ -1473,14 +1616,14 @@ describe('State Machine handler tests', function () {
1473
1616
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1474
1617
  case 14:
1475
1618
  case "end":
1476
- return _context26.stop();
1619
+ return _context30.stop();
1477
1620
  }
1478
- }, _callee26);
1621
+ }, _callee30);
1479
1622
  })));
1480
- it('Outgoing Roap answer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1623
+ it('Outgoing Roap answer retry-after error case during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1481
1624
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1482
- return _regenerator.default.wrap(function _callee27$(_context27) {
1483
- while (1) switch (_context27.prev = _context27.next) {
1625
+ return _regenerator.default.wrap(function _callee31$(_context31) {
1626
+ while (1) switch (_context31.prev = _context31.next) {
1484
1627
  case 0:
1485
1628
  statusPayload = {
1486
1629
  statusCode: 503,
@@ -1501,7 +1644,7 @@ describe('State Machine handler tests', function () {
1501
1644
  }
1502
1645
  };
1503
1646
  call['connected'] = false;
1504
- _context27.next = 8;
1647
+ _context31.next = 8;
1505
1648
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
1506
1649
  case 8:
1507
1650
  jest.advanceTimersByTime(1005);
@@ -1513,14 +1656,14 @@ describe('State Machine handler tests', function () {
1513
1656
  expect(stateMachineSpy).not.toBeCalled();
1514
1657
  case 13:
1515
1658
  case "end":
1516
- return _context27.stop();
1659
+ return _context31.stop();
1517
1660
  }
1518
- }, _callee27);
1661
+ }, _callee31);
1519
1662
  })));
1520
- it('ROAP error during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1663
+ it('ROAP error during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1521
1664
  var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
1522
- return _regenerator.default.wrap(function _callee28$(_context28) {
1523
- while (1) switch (_context28.prev = _context28.next) {
1665
+ return _regenerator.default.wrap(function _callee32$(_context32) {
1666
+ while (1) switch (_context32.prev = _context32.next) {
1524
1667
  case 0:
1525
1668
  statusPayload = {
1526
1669
  statusCode: 200,
@@ -1545,14 +1688,14 @@ describe('State Machine handler tests', function () {
1545
1688
  expect(stateMachineSpy).not.toHaveBeenCalled();
1546
1689
  case 11:
1547
1690
  case "end":
1548
- return _context28.stop();
1691
+ return _context32.stop();
1549
1692
  }
1550
- }, _callee28);
1693
+ }, _callee32);
1551
1694
  })));
1552
- it('ROAP ok retry-after during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1695
+ it('ROAP ok retry-after during mid call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
1553
1696
  var statusPayload, funcSpy, stateMachineSpy, dummyEvent;
1554
- return _regenerator.default.wrap(function _callee29$(_context29) {
1555
- while (1) switch (_context29.prev = _context29.next) {
1697
+ return _regenerator.default.wrap(function _callee33$(_context33) {
1698
+ while (1) switch (_context33.prev = _context33.next) {
1556
1699
  case 0:
1557
1700
  statusPayload = {
1558
1701
  statusCode: 503,
@@ -1574,7 +1717,7 @@ describe('State Machine handler tests', function () {
1574
1717
  };
1575
1718
  call['connected'] = true;
1576
1719
  call['mediaStateMachine'].state.value = 'S_RECV_ROAP_ANSWER';
1577
- _context29.next = 9;
1720
+ _context33.next = 9;
1578
1721
  return call['handleRoapEstablished']({}, dummyEvent);
1579
1722
  case 9:
1580
1723
  jest.advanceTimersByTime(1005);
@@ -1586,14 +1729,14 @@ describe('State Machine handler tests', function () {
1586
1729
  expect(stateMachineSpy).toBeCalledOnceWith(dummyEvent);
1587
1730
  case 14:
1588
1731
  case "end":
1589
- return _context29.stop();
1732
+ return _context33.stop();
1590
1733
  }
1591
- }, _callee29);
1734
+ }, _callee33);
1592
1735
  })));
1593
- it('Unable to communicate roap error with mobius', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1736
+ it('Unable to communicate roap error with mobius', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
1594
1737
  var statusPayload, stateMachineSpy, funcSpy, errorEvent;
1595
- return _regenerator.default.wrap(function _callee30$(_context30) {
1596
- while (1) switch (_context30.prev = _context30.next) {
1738
+ return _regenerator.default.wrap(function _callee34$(_context34) {
1739
+ while (1) switch (_context34.prev = _context34.next) {
1597
1740
  case 0:
1598
1741
  statusPayload = {
1599
1742
  statusCode: 403,
@@ -1616,14 +1759,14 @@ describe('State Machine handler tests', function () {
1616
1759
  expect(stateMachineSpy).not.toHaveBeenCalled();
1617
1760
  case 9:
1618
1761
  case "end":
1619
- return _context30.stop();
1762
+ return _context34.stop();
1620
1763
  }
1621
- }, _callee30);
1764
+ }, _callee34);
1622
1765
  })));
1623
- it('ROAP error during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31() {
1766
+ it('ROAP error during call establishment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
1624
1767
  var statusPayload, warnSpy, stateMachineSpy, funcSpy, errorEvent;
1625
- return _regenerator.default.wrap(function _callee31$(_context31) {
1626
- while (1) switch (_context31.prev = _context31.next) {
1768
+ return _regenerator.default.wrap(function _callee35$(_context35) {
1769
+ while (1) switch (_context35.prev = _context35.next) {
1627
1770
  case 0:
1628
1771
  statusPayload = {
1629
1772
  statusCode: 200,
@@ -1641,7 +1784,7 @@ describe('State Machine handler tests', function () {
1641
1784
  }
1642
1785
  };
1643
1786
  call['connected'] = false;
1644
- _context31.next = 8;
1787
+ _context35.next = 8;
1645
1788
  return call['handleRoapError']({}, errorEvent);
1646
1789
  case 8:
1647
1790
  expect(funcSpy).toBeCalledOnceWith(errorEvent.data);
@@ -1657,14 +1800,80 @@ describe('State Machine handler tests', function () {
1657
1800
  });
1658
1801
  case 11:
1659
1802
  case "end":
1660
- return _context31.stop();
1803
+ return _context35.stop();
1661
1804
  }
1662
- }, _callee31);
1805
+ }, _callee35);
1663
1806
  })));
1664
- it('state changes during successful incoming call with out of order events', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
1807
+ it('incoming call: failing ROAP_ANSWER posts error path and tears down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
1808
+ var statusPayload, warnSpy, postMediaSpy, setupEvent, connectEvent, offerEvent, answerEvent;
1809
+ return _regenerator.default.wrap(function _callee36$(_context36) {
1810
+ while (1) switch (_context36.prev = _context36.next) {
1811
+ case 0:
1812
+ statusPayload = {
1813
+ statusCode: 403,
1814
+ body: mockStatusBody
1815
+ };
1816
+ warnSpy = jest.spyOn(_Logger.default, 'warn');
1817
+ postMediaSpy = jest.spyOn(call, 'postMedia').mockRejectedValueOnce(statusPayload); // Simulate inbound call flow
1818
+ call['direction'] = _types3.CallDirection.INBOUND;
1819
+ setupEvent = {
1820
+ type: 'E_RECV_CALL_SETUP',
1821
+ data: {
1822
+ seq: 1,
1823
+ messageType: 'OFFER'
1824
+ }
1825
+ };
1826
+ call.sendCallStateMachineEvt(setupEvent);
1827
+ expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_PROGRESS');
1828
+ connectEvent = {
1829
+ type: 'E_SEND_CALL_CONNECT'
1830
+ };
1831
+ call.sendCallStateMachineEvt(connectEvent);
1832
+ expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_CONNECT');
1833
+ offerEvent = {
1834
+ type: 'E_RECV_ROAP_OFFER',
1835
+ data: {
1836
+ seq: 1,
1837
+ messageType: 'OFFER'
1838
+ }
1839
+ };
1840
+ call.sendMediaStateMachineEvt(offerEvent);
1841
+ answerEvent = {
1842
+ type: 'E_SEND_ROAP_ANSWER',
1843
+ data: {
1844
+ seq: 1,
1845
+ messageType: 'ANSWER'
1846
+ }
1847
+ };
1848
+ _context36.next = 15;
1849
+ return call.sendMediaStateMachineEvt(answerEvent);
1850
+ case 15:
1851
+ _context36.next = 17;
1852
+ return (0, _testUtil.flushPromises)(2);
1853
+ case 17:
1854
+ expect(postMediaSpy).toBeCalledOnceWith(answerEvent.data);
1855
+ expect(warnSpy).toHaveBeenCalledWith('Failed to send MediaAnswer request', {
1856
+ file: 'call',
1857
+ method: 'handleOutgoingRoapAnswer'
1858
+ });
1859
+ expect(warnSpy).toHaveBeenCalledWith('Call failed due to media issue', {
1860
+ file: 'call',
1861
+ method: 'handleRoapError'
1862
+ });
1863
+
1864
+ // Final state should be torn down and cleared for unconnected call
1865
+ expect(call['mediaStateMachine'].state.value).toBe('S_ROAP_TEARDOWN');
1866
+ expect(call['callStateMachine'].state.value).toBe('S_CALL_CLEARED');
1867
+ case 22:
1868
+ case "end":
1869
+ return _context36.stop();
1870
+ }
1871
+ }, _callee36);
1872
+ })));
1873
+ it('state changes during successful incoming call with out of order events', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
1665
1874
  var statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
1666
- return _regenerator.default.wrap(function _callee32$(_context32) {
1667
- while (1) switch (_context32.prev = _context32.next) {
1875
+ return _regenerator.default.wrap(function _callee37$(_context37) {
1876
+ while (1) switch (_context37.prev = _context37.next) {
1668
1877
  case 0:
1669
1878
  statusPayload = {
1670
1879
  statusCode: 200,
@@ -1697,7 +1906,7 @@ describe('State Machine handler tests', function () {
1697
1906
  seq: 1,
1698
1907
  messageType: 'ANSWER'
1699
1908
  };
1700
- _context32.next = 17;
1909
+ _context37.next = 17;
1701
1910
  return call.sendMediaStateMachineEvt(dummyEvent);
1702
1911
  case 17:
1703
1912
  expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
@@ -1719,7 +1928,7 @@ describe('State Machine handler tests', function () {
1719
1928
  seq: 2,
1720
1929
  messageType: 'OFFER_REQUEST'
1721
1930
  };
1722
- _context32.next = 23;
1931
+ _context37.next = 23;
1723
1932
  return call.sendMediaStateMachineEvt(dummyEvent);
1724
1933
  case 23:
1725
1934
  expect(call['receivedRoapOKSeq']).toBe(0);
@@ -1769,7 +1978,7 @@ describe('State Machine handler tests', function () {
1769
1978
  };
1770
1979
  call.sendCallStateMachineEvt(dummyEvent);
1771
1980
  dummyEvent.type = 'E_RECV_ROAP_OFFER';
1772
- _context32.next = 49;
1981
+ _context37.next = 49;
1773
1982
  return call.sendMediaStateMachineEvt(dummyEvent);
1774
1983
  case 49:
1775
1984
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1778,7 +1987,7 @@ describe('State Machine handler tests', function () {
1778
1987
  seq: 3,
1779
1988
  messageType: 'ANSWER'
1780
1989
  };
1781
- _context32.next = 54;
1990
+ _context37.next = 54;
1782
1991
  return call.sendMediaStateMachineEvt(dummyEvent);
1783
1992
  case 54:
1784
1993
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1797,7 +2006,7 @@ describe('State Machine handler tests', function () {
1797
2006
  messageType: 'OK'
1798
2007
  }
1799
2008
  };
1800
- _context32.next = 63;
2009
+ _context37.next = 63;
1801
2010
  return call.sendMediaStateMachineEvt(dummyOkEvent);
1802
2011
  case 63:
1803
2012
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenNthCalledWith(6, dummyOkEvent.data.message);
@@ -1812,14 +2021,14 @@ describe('State Machine handler tests', function () {
1812
2021
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
1813
2022
  case 70:
1814
2023
  case "end":
1815
- return _context32.stop();
2024
+ return _context37.stop();
1816
2025
  }
1817
- }, _callee32);
2026
+ }, _callee37);
1818
2027
  })));
1819
- it('successfully handles out of order events when ROAP OK is received while executing outgoingRoapAnswer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
2028
+ it('successfully handles out of order events when ROAP OK is received while executing outgoingRoapAnswer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
1820
2029
  var mockStatusBody, statusPayload, dummyEvent, postMediaSpy, dummyOkEvent, dummyOfferEvent;
1821
- return _regenerator.default.wrap(function _callee33$(_context33) {
1822
- while (1) switch (_context33.prev = _context33.next) {
2030
+ return _regenerator.default.wrap(function _callee38$(_context38) {
2031
+ while (1) switch (_context38.prev = _context38.next) {
1823
2032
  case 0:
1824
2033
  mockStatusBody = {
1825
2034
  device: {
@@ -1859,7 +2068,7 @@ describe('State Machine handler tests', function () {
1859
2068
  seq: 1,
1860
2069
  messageType: 'ANSWER'
1861
2070
  };
1862
- _context33.next = 18;
2071
+ _context38.next = 18;
1863
2072
  return call.sendMediaStateMachineEvt(dummyEvent);
1864
2073
  case 18:
1865
2074
  expect(postMediaSpy).toBeCalledOnceWith(dummyEvent.data);
@@ -1881,7 +2090,7 @@ describe('State Machine handler tests', function () {
1881
2090
  seq: 2,
1882
2091
  messageType: 'OFFER_REQUEST'
1883
2092
  };
1884
- _context33.next = 24;
2093
+ _context38.next = 24;
1885
2094
  return call.sendMediaStateMachineEvt(dummyEvent);
1886
2095
  case 24:
1887
2096
  expect(call['receivedRoapOKSeq']).toBe(0);
@@ -1931,7 +2140,7 @@ describe('State Machine handler tests', function () {
1931
2140
  };
1932
2141
  call.sendCallStateMachineEvt(dummyEvent);
1933
2142
  dummyEvent.type = 'E_RECV_ROAP_OFFER';
1934
- _context33.next = 50;
2143
+ _context38.next = 50;
1935
2144
  return call.sendMediaStateMachineEvt(dummyEvent);
1936
2145
  case 50:
1937
2146
  expect(_testUtil.mediaConnection.roapMessageReceived).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1940,7 +2149,7 @@ describe('State Machine handler tests', function () {
1940
2149
  seq: 3,
1941
2150
  messageType: 'ANSWER'
1942
2151
  };
1943
- _context33.next = 55;
2152
+ _context38.next = 55;
1944
2153
  return call.sendMediaStateMachineEvt(dummyEvent);
1945
2154
  case 55:
1946
2155
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
@@ -1957,7 +2166,7 @@ describe('State Machine handler tests', function () {
1957
2166
  }
1958
2167
  };
1959
2168
  call.sendMediaStateMachineEvt(dummyEvent);
1960
- _context33.next = 62;
2169
+ _context38.next = 62;
1961
2170
  return call.sendMediaStateMachineEvt(dummyOkEvent);
1962
2171
  case 62:
1963
2172
  expect(call['receivedRoapOKSeq']).toBe(3);
@@ -1973,14 +2182,14 @@ describe('State Machine handler tests', function () {
1973
2182
  expect(postMediaSpy).toHaveBeenLastCalledWith(dummyEvent.data);
1974
2183
  case 70:
1975
2184
  case "end":
1976
- return _context33.stop();
2185
+ return _context38.stop();
1977
2186
  }
1978
- }, _callee33);
2187
+ }, _callee38);
1979
2188
  })));
1980
- it('handle hold event successfully when media received after progress but before connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
2189
+ it('handle hold event successfully when media received after progress but before connect', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
1981
2190
  var statusPayload, dummyEvent, postMediaSpy, infoSpy, dummyOkEvent;
1982
- return _regenerator.default.wrap(function _callee34$(_context34) {
1983
- while (1) switch (_context34.prev = _context34.next) {
2191
+ return _regenerator.default.wrap(function _callee39$(_context39) {
2192
+ while (1) switch (_context39.prev = _context39.next) {
1984
2193
  case 0:
1985
2194
  statusPayload = {
1986
2195
  statusCode: 200,
@@ -2047,9 +2256,33 @@ describe('State Machine handler tests', function () {
2047
2256
  });
2048
2257
  case 33:
2049
2258
  case "end":
2050
- return _context34.stop();
2259
+ return _context39.stop();
2051
2260
  }
2052
- }, _callee34);
2261
+ }, _callee39);
2262
+ })));
2263
+ it('emits DISCONNECT before mobius delete request is invoked', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
2264
+ var emitSpy, deleteSpy;
2265
+ return _regenerator.default.wrap(function _callee40$(_context40) {
2266
+ while (1) switch (_context40.prev = _context40.next) {
2267
+ case 0:
2268
+ emitSpy = jest.spyOn(call, 'emit');
2269
+ deleteSpy = jest.spyOn(call, 'delete').mockResolvedValue({
2270
+ statusCode: 200
2271
+ });
2272
+ call.sendCallStateMachineEvt({
2273
+ type: 'E_RECV_CALL_DISCONNECT'
2274
+ });
2275
+ _context40.next = 5;
2276
+ return (0, _testUtil.flushPromises)(1);
2277
+ case 5:
2278
+ expect(emitSpy).toHaveBeenCalledWith(_types2.CALL_EVENT_KEYS.DISCONNECT, call.getCorrelationId());
2279
+ expect(deleteSpy).toHaveBeenCalled();
2280
+ expect(emitSpy.mock.invocationCallOrder[0]).toBeLessThan(deleteSpy.mock.invocationCallOrder[0]);
2281
+ case 8:
2282
+ case "end":
2283
+ return _context40.stop();
2284
+ }
2285
+ }, _callee40);
2053
2286
  })));
2054
2287
  describe('Call event timers tests', function () {
2055
2288
  var callManager;
@@ -2060,10 +2293,10 @@ describe('State Machine handler tests', function () {
2060
2293
  afterEach(function () {
2061
2294
  jest.clearAllTimers();
2062
2295
  });
2063
- it('times out if the next event is not received - 60 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
2296
+ it('times out if the next event is not received - 60 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
2064
2297
  var statusPayload, dummyEvent, logSpy, emitSpy, deleteSpy, dummyOkEvent;
2065
- return _regenerator.default.wrap(function _callee35$(_context35) {
2066
- while (1) switch (_context35.prev = _context35.next) {
2298
+ return _regenerator.default.wrap(function _callee41$(_context41) {
2299
+ while (1) switch (_context41.prev = _context41.next) {
2067
2300
  case 0:
2068
2301
  statusPayload = {
2069
2302
  statusCode: 200,
@@ -2080,7 +2313,7 @@ describe('State Machine handler tests', function () {
2080
2313
  webex.request.mockReturnValue(statusPayload);
2081
2314
 
2082
2315
  // handleOutgoingCallSetup is asynchronous
2083
- _context35.next = 9;
2316
+ _context41.next = 9;
2084
2317
  return call.sendCallStateMachineEvt(dummyEvent);
2085
2318
  case 9:
2086
2319
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
@@ -2123,14 +2356,14 @@ describe('State Machine handler tests', function () {
2123
2356
  expect(callManager.callCollection).toStrictEqual({});
2124
2357
  case 32:
2125
2358
  case "end":
2126
- return _context35.stop();
2359
+ return _context41.stop();
2127
2360
  }
2128
- }, _callee35);
2361
+ }, _callee41);
2129
2362
  })));
2130
- it('times out if the next event is not received - 10 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
2363
+ it('times out if the next event is not received - 10 seconds timeout', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
2131
2364
  var statusPayload, dummyEvent, call, emitSpy, deleteSpy, logSpy;
2132
- return _regenerator.default.wrap(function _callee36$(_context36) {
2133
- while (1) switch (_context36.prev = _context36.next) {
2365
+ return _regenerator.default.wrap(function _callee42$(_context42) {
2366
+ while (1) switch (_context42.prev = _context42.next) {
2134
2367
  case 0:
2135
2368
  statusPayload = {
2136
2369
  statusCode: 200,
@@ -2149,7 +2382,7 @@ describe('State Machine handler tests', function () {
2149
2382
  expect((0, _keys.default)(callManager.callCollection)[0]).toBe(call.getCorrelationId());
2150
2383
 
2151
2384
  // handleOutgoingCallSetup is asynchronous
2152
- _context36.next = 11;
2385
+ _context42.next = 11;
2153
2386
  return call.sendCallStateMachineEvt(dummyEvent);
2154
2387
  case 11:
2155
2388
  expect(call['callStateMachine'].state.value).toBe('S_SEND_CALL_SETUP');
@@ -2161,9 +2394,9 @@ describe('State Machine handler tests', function () {
2161
2394
  expect(callManager.callCollection).toStrictEqual({});
2162
2395
  case 18:
2163
2396
  case "end":
2164
- return _context36.stop();
2397
+ return _context42.stop();
2165
2398
  }
2166
- }, _callee36);
2399
+ }, _callee42);
2167
2400
  })));
2168
2401
  });
2169
2402
  });
@@ -2223,10 +2456,10 @@ describe('Supplementary Services tests', function () {
2223
2456
  beforeEach(function () {
2224
2457
  call.removeAllListeners();
2225
2458
  });
2226
- it('Handle successful Call hold case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
2459
+ it('Handle successful Call hold case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
2227
2460
  var responsePayload, warnSpy, roapEvent;
2228
- return _regenerator.default.wrap(function _callee38$(_context38) {
2229
- while (1) switch (_context38.prev = _context38.next) {
2461
+ return _regenerator.default.wrap(function _callee44$(_context44) {
2462
+ while (1) switch (_context44.prev = _context44.next) {
2230
2463
  case 0:
2231
2464
  expect.assertions(7);
2232
2465
  responsePayload = {
@@ -2239,25 +2472,25 @@ describe('Supplementary Services tests', function () {
2239
2472
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2240
2473
  call['held'] = false;
2241
2474
  call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
2242
- var _ref38 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37(correlationId) {
2243
- return _regenerator.default.wrap(function _callee37$(_context37) {
2244
- while (1) switch (_context37.prev = _context37.next) {
2475
+ var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43(correlationId) {
2476
+ return _regenerator.default.wrap(function _callee43$(_context43) {
2477
+ while (1) switch (_context43.prev = _context43.next) {
2245
2478
  case 0:
2246
2479
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2247
2480
  case 1:
2248
2481
  case "end":
2249
- return _context37.stop();
2482
+ return _context43.stop();
2250
2483
  }
2251
- }, _callee37);
2484
+ }, _callee43);
2252
2485
  }));
2253
2486
  return function (_x) {
2254
- return _ref38.apply(this, arguments);
2487
+ return _ref44.apply(this, arguments);
2255
2488
  };
2256
2489
  }());
2257
- _context38.next = 10;
2490
+ _context44.next = 10;
2258
2491
  return call.doHoldResume();
2259
2492
  case 10:
2260
- _context38.next = 12;
2493
+ _context44.next = 12;
2261
2494
  return (0, _testUtil.flushPromises)(2);
2262
2495
  case 12:
2263
2496
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2273,11 +2506,11 @@ describe('Supplementary Services tests', function () {
2273
2506
  call['handleIncomingRoapOffer']({}, dummyEvent);
2274
2507
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2275
2508
  roapEvent.data.type = 'ANSWER';
2276
- _context38.next = 20;
2509
+ _context44.next = 20;
2277
2510
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2278
2511
  case 20:
2279
2512
  roapEvent.data.type = 'OK';
2280
- _context38.next = 23;
2513
+ _context44.next = 23;
2281
2514
  return call['handleRoapEstablished']({}, dummyEvent);
2282
2515
  case 23:
2283
2516
  expect(clearTimeout).toHaveBeenCalledTimes(1);
@@ -2292,14 +2525,14 @@ describe('Supplementary Services tests', function () {
2292
2525
  });
2293
2526
  case 28:
2294
2527
  case "end":
2295
- return _context38.stop();
2528
+ return _context44.stop();
2296
2529
  }
2297
- }, _callee38);
2530
+ }, _callee44);
2298
2531
  })));
2299
- it('Handle successful Call hold case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
2532
+ it('Handle successful Call hold case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
2300
2533
  var responsePayload, warnSpy, roapEvent;
2301
- return _regenerator.default.wrap(function _callee40$(_context40) {
2302
- while (1) switch (_context40.prev = _context40.next) {
2534
+ return _regenerator.default.wrap(function _callee46$(_context46) {
2535
+ while (1) switch (_context46.prev = _context46.next) {
2303
2536
  case 0:
2304
2537
  expect.assertions(8);
2305
2538
  responsePayload = {
@@ -2312,26 +2545,26 @@ describe('Supplementary Services tests', function () {
2312
2545
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2313
2546
  call['held'] = false;
2314
2547
  call.on(_types2.CALL_EVENT_KEYS.HELD, /*#__PURE__*/function () {
2315
- var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(correlationId) {
2316
- return _regenerator.default.wrap(function _callee39$(_context39) {
2317
- while (1) switch (_context39.prev = _context39.next) {
2548
+ var _ref46 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(correlationId) {
2549
+ return _regenerator.default.wrap(function _callee45$(_context45) {
2550
+ while (1) switch (_context45.prev = _context45.next) {
2318
2551
  case 0:
2319
2552
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2320
2553
  case 1:
2321
2554
  case "end":
2322
- return _context39.stop();
2555
+ return _context45.stop();
2323
2556
  }
2324
- }, _callee39);
2557
+ }, _callee45);
2325
2558
  }));
2326
2559
  return function (_x2) {
2327
- return _ref40.apply(this, arguments);
2560
+ return _ref46.apply(this, arguments);
2328
2561
  };
2329
2562
  }());
2330
2563
  call.doHoldResume();
2331
- _context40.next = 11;
2564
+ _context46.next = 11;
2332
2565
  return _promise.default.resolve();
2333
2566
  case 11:
2334
- _context40.next = 13;
2567
+ _context46.next = 13;
2335
2568
  return _promise.default.resolve();
2336
2569
  case 13:
2337
2570
  expect(setTimeout).not.toHaveBeenCalled();
@@ -2347,11 +2580,11 @@ describe('Supplementary Services tests', function () {
2347
2580
  call['handleIncomingRoapOffer']({}, dummyEvent);
2348
2581
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2349
2582
  roapEvent.data.type = 'ANSWER';
2350
- _context40.next = 22;
2583
+ _context46.next = 22;
2351
2584
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2352
2585
  case 22:
2353
2586
  roapEvent.data.type = 'OK';
2354
- _context40.next = 25;
2587
+ _context46.next = 25;
2355
2588
  return call['handleRoapEstablished']({}, dummyEvent);
2356
2589
  case 25:
2357
2590
  expect(clearTimeout).not.toHaveBeenCalled();
@@ -2366,14 +2599,14 @@ describe('Supplementary Services tests', function () {
2366
2599
  });
2367
2600
  case 30:
2368
2601
  case "end":
2369
- return _context40.stop();
2602
+ return _context46.stop();
2370
2603
  }
2371
- }, _callee40);
2604
+ }, _callee46);
2372
2605
  })));
2373
- it('Handle failure Call Hold case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
2606
+ it('Handle failure Call Hold case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
2374
2607
  var responsePayload;
2375
- return _regenerator.default.wrap(function _callee42$(_context42) {
2376
- while (1) switch (_context42.prev = _context42.next) {
2608
+ return _regenerator.default.wrap(function _callee48$(_context48) {
2609
+ while (1) switch (_context48.prev = _context48.next) {
2377
2610
  case 0:
2378
2611
  expect.assertions(4);
2379
2612
  responsePayload = {
@@ -2383,26 +2616,26 @@ describe('Supplementary Services tests', function () {
2383
2616
  jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
2384
2617
  call['held'] = false;
2385
2618
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2386
- var _ref42 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41(errObj) {
2387
- return _regenerator.default.wrap(function _callee41$(_context41) {
2388
- while (1) switch (_context41.prev = _context41.next) {
2619
+ var _ref48 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47(errObj) {
2620
+ return _regenerator.default.wrap(function _callee47$(_context47) {
2621
+ while (1) switch (_context47.prev = _context47.next) {
2389
2622
  case 0:
2390
2623
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2391
2624
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2392
2625
  case 2:
2393
2626
  case "end":
2394
- return _context41.stop();
2627
+ return _context47.stop();
2395
2628
  }
2396
- }, _callee41);
2629
+ }, _callee47);
2397
2630
  }));
2398
2631
  return function (_x3) {
2399
- return _ref42.apply(this, arguments);
2632
+ return _ref48.apply(this, arguments);
2400
2633
  };
2401
2634
  }());
2402
- _context42.next = 7;
2635
+ _context48.next = 7;
2403
2636
  return call.doHoldResume();
2404
2637
  case 7:
2405
- _context42.next = 9;
2638
+ _context48.next = 9;
2406
2639
  return (0, _testUtil.flushPromises)(2);
2407
2640
  case 9:
2408
2641
  expect(call.isHeld()).toStrictEqual(false);
@@ -2412,14 +2645,14 @@ describe('Supplementary Services tests', function () {
2412
2645
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2413
2646
  case 11:
2414
2647
  case "end":
2415
- return _context42.stop();
2648
+ return _context48.stop();
2416
2649
  }
2417
- }, _callee42);
2650
+ }, _callee48);
2418
2651
  })));
2419
- it('Handle failure Call Hold case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
2652
+ it('Handle failure Call Hold case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
2420
2653
  var responsePayload, rejectPayload, roapEvent;
2421
- return _regenerator.default.wrap(function _callee44$(_context44) {
2422
- while (1) switch (_context44.prev = _context44.next) {
2654
+ return _regenerator.default.wrap(function _callee50$(_context50) {
2655
+ while (1) switch (_context50.prev = _context50.next) {
2423
2656
  case 0:
2424
2657
  expect.assertions(5);
2425
2658
  responsePayload = {
@@ -2433,24 +2666,24 @@ describe('Supplementary Services tests', function () {
2433
2666
  jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
2434
2667
  call['held'] = false;
2435
2668
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2436
- var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43(errObj) {
2437
- return _regenerator.default.wrap(function _callee43$(_context43) {
2438
- while (1) switch (_context43.prev = _context43.next) {
2669
+ var _ref50 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49(errObj) {
2670
+ return _regenerator.default.wrap(function _callee49$(_context49) {
2671
+ while (1) switch (_context49.prev = _context49.next) {
2439
2672
  case 0:
2440
2673
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2441
2674
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2442
2675
  case 2:
2443
2676
  case "end":
2444
- return _context43.stop();
2677
+ return _context49.stop();
2445
2678
  }
2446
- }, _callee43);
2679
+ }, _callee49);
2447
2680
  }));
2448
2681
  return function (_x4) {
2449
- return _ref44.apply(this, arguments);
2682
+ return _ref50.apply(this, arguments);
2450
2683
  };
2451
2684
  }());
2452
2685
  call.doHoldResume();
2453
- _context44.next = 9;
2686
+ _context50.next = 9;
2454
2687
  return (0, _testUtil.flushPromises)(2);
2455
2688
  case 9:
2456
2689
  /* the Call State should transition to S_CALL_ESTABLISHED
@@ -2460,7 +2693,7 @@ describe('Supplementary Services tests', function () {
2460
2693
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2461
2694
  /* We are intentionally failing the ROAP ANSWER */
2462
2695
  roapEvent.data.type = 'ANSWER';
2463
- _context44.next = 15;
2696
+ _context50.next = 15;
2464
2697
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2465
2698
  case 15:
2466
2699
  expect(call.isHeld()).toStrictEqual(false);
@@ -2468,14 +2701,14 @@ describe('Supplementary Services tests', function () {
2468
2701
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2469
2702
  case 17:
2470
2703
  case "end":
2471
- return _context44.stop();
2704
+ return _context50.stop();
2472
2705
  }
2473
- }, _callee44);
2706
+ }, _callee50);
2474
2707
  })));
2475
- it('Handle failure Call Hold case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45() {
2708
+ it('Handle failure Call Hold case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
2476
2709
  var responsePayload, warnSpy, roapEvent;
2477
- return _regenerator.default.wrap(function _callee45$(_context45) {
2478
- while (1) switch (_context45.prev = _context45.next) {
2710
+ return _regenerator.default.wrap(function _callee51$(_context51) {
2711
+ while (1) switch (_context51.prev = _context51.next) {
2479
2712
  case 0:
2480
2713
  responsePayload = {
2481
2714
  statusCode: 200,
@@ -2486,10 +2719,10 @@ describe('Supplementary Services tests', function () {
2486
2719
  jest.spyOn(global, 'clearTimeout');
2487
2720
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2488
2721
  call['held'] = false;
2489
- _context45.next = 8;
2722
+ _context51.next = 8;
2490
2723
  return call.doHoldResume();
2491
2724
  case 8:
2492
- _context45.next = 10;
2725
+ _context51.next = 10;
2493
2726
  return (0, _testUtil.flushPromises)(2);
2494
2727
  case 10:
2495
2728
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2504,19 +2737,19 @@ describe('Supplementary Services tests', function () {
2504
2737
  call['handleIncomingRoapOffer']({}, dummyEvent);
2505
2738
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2506
2739
  roapEvent.data.type = 'ANSWER';
2507
- _context45.next = 17;
2740
+ _context51.next = 17;
2508
2741
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2509
2742
  case 17:
2510
2743
  jest.spyOn(webex, 'request').mockRejectedValue({
2511
2744
  statusCode: 403
2512
2745
  });
2513
2746
  roapEvent.data.type = 'OK';
2514
- _context45.next = 21;
2747
+ _context51.next = 21;
2515
2748
  return call['handleRoapEstablished']({}, dummyEvent);
2516
2749
  case 21:
2517
2750
  /* this is for coverage */
2518
2751
  call['callStateMachine'].state.value = 'S_CALL_HOLD';
2519
- _context45.next = 24;
2752
+ _context51.next = 24;
2520
2753
  return call['handleRoapEstablished']({}, dummyEvent);
2521
2754
  case 24:
2522
2755
  expect(call.isHeld()).toStrictEqual(false);
@@ -2528,14 +2761,14 @@ describe('Supplementary Services tests', function () {
2528
2761
  });
2529
2762
  case 27:
2530
2763
  case "end":
2531
- return _context45.stop();
2764
+ return _context51.stop();
2532
2765
  }
2533
- }, _callee45);
2766
+ }, _callee51);
2534
2767
  })));
2535
- it('Handle failure Call resume case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
2768
+ it('Handle failure Call resume case during roap ok out', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
2536
2769
  var responsePayload, warnSpy, roapEvent;
2537
- return _regenerator.default.wrap(function _callee46$(_context46) {
2538
- while (1) switch (_context46.prev = _context46.next) {
2770
+ return _regenerator.default.wrap(function _callee52$(_context52) {
2771
+ while (1) switch (_context52.prev = _context52.next) {
2539
2772
  case 0:
2540
2773
  responsePayload = {
2541
2774
  statusCode: 200,
@@ -2546,10 +2779,10 @@ describe('Supplementary Services tests', function () {
2546
2779
  jest.spyOn(global, 'clearTimeout');
2547
2780
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2548
2781
  call['held'] = true;
2549
- _context46.next = 8;
2782
+ _context52.next = 8;
2550
2783
  return call.doHoldResume();
2551
2784
  case 8:
2552
- _context46.next = 10;
2785
+ _context52.next = 10;
2553
2786
  return (0, _testUtil.flushPromises)(2);
2554
2787
  case 10:
2555
2788
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2564,14 +2797,14 @@ describe('Supplementary Services tests', function () {
2564
2797
  call['handleIncomingRoapOffer']({}, dummyEvent);
2565
2798
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2566
2799
  roapEvent.data.type = 'ANSWER';
2567
- _context46.next = 17;
2800
+ _context52.next = 17;
2568
2801
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2569
2802
  case 17:
2570
2803
  jest.spyOn(webex, 'request').mockRejectedValue({
2571
2804
  statusCode: 403
2572
2805
  });
2573
2806
  roapEvent.data.type = 'OK';
2574
- _context46.next = 21;
2807
+ _context52.next = 21;
2575
2808
  return call['handleRoapEstablished']({}, dummyEvent);
2576
2809
  case 21:
2577
2810
  expect(call.isHeld()).toStrictEqual(true);
@@ -2583,14 +2816,14 @@ describe('Supplementary Services tests', function () {
2583
2816
  });
2584
2817
  case 24:
2585
2818
  case "end":
2586
- return _context46.stop();
2819
+ return _context52.stop();
2587
2820
  }
2588
- }, _callee46);
2821
+ }, _callee52);
2589
2822
  })));
2590
- it('Handle Call hold case where successful Held response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
2823
+ it('Handle Call hold case where successful Held response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
2591
2824
  var responsePayload, roapEvent;
2592
- return _regenerator.default.wrap(function _callee48$(_context48) {
2593
- while (1) switch (_context48.prev = _context48.next) {
2825
+ return _regenerator.default.wrap(function _callee54$(_context54) {
2826
+ while (1) switch (_context54.prev = _context54.next) {
2594
2827
  case 0:
2595
2828
  expect.assertions(5);
2596
2829
  responsePayload = {
@@ -2600,25 +2833,25 @@ describe('Supplementary Services tests', function () {
2600
2833
  jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
2601
2834
  call['held'] = false;
2602
2835
  call.on(_types2.CALL_EVENT_KEYS.HOLD_ERROR, /*#__PURE__*/function () {
2603
- var _ref48 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47(errObj) {
2604
- return _regenerator.default.wrap(function _callee47$(_context47) {
2605
- while (1) switch (_context47.prev = _context47.next) {
2836
+ var _ref54 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53(errObj) {
2837
+ return _regenerator.default.wrap(function _callee53$(_context53) {
2838
+ while (1) switch (_context53.prev = _context53.next) {
2606
2839
  case 0:
2607
2840
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
2608
2841
  expect(errObj.message).toStrictEqual('An error occurred while placing the call on hold. Wait a moment and try again.');
2609
2842
  case 2:
2610
2843
  case "end":
2611
- return _context47.stop();
2844
+ return _context53.stop();
2612
2845
  }
2613
- }, _callee47);
2846
+ }, _callee53);
2614
2847
  }));
2615
2848
  return function (_x5) {
2616
- return _ref48.apply(this, arguments);
2849
+ return _ref54.apply(this, arguments);
2617
2850
  };
2618
2851
  }());
2619
2852
  jest.runAllTimers();
2620
2853
  call.doHoldResume();
2621
- _context48.next = 9;
2854
+ _context54.next = 9;
2622
2855
  return (0, _testUtil.flushPromises)(2);
2623
2856
  case 9:
2624
2857
  /* At this point, the Call State should be S_CALL_HOLD
@@ -2631,11 +2864,11 @@ describe('Supplementary Services tests', function () {
2631
2864
  call['handleIncomingRoapOffer']({}, dummyEvent);
2632
2865
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2633
2866
  roapEvent.data.type = 'ANSWER';
2634
- _context48.next = 15;
2867
+ _context54.next = 15;
2635
2868
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2636
2869
  case 15:
2637
2870
  roapEvent.data.type = 'OK';
2638
- _context48.next = 18;
2871
+ _context54.next = 18;
2639
2872
  return call['handleRoapEstablished']({}, dummyEvent);
2640
2873
  case 18:
2641
2874
  /* Advancing timer by 12 seconds so that it gets timed out */
@@ -2647,14 +2880,14 @@ describe('Supplementary Services tests', function () {
2647
2880
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2648
2881
  case 21:
2649
2882
  case "end":
2650
- return _context48.stop();
2883
+ return _context54.stop();
2651
2884
  }
2652
- }, _callee48);
2885
+ }, _callee54);
2653
2886
  })));
2654
- it('Handle successful Call Resume case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
2887
+ it('Handle successful Call Resume case without delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
2655
2888
  var responsePayload, warnSpy, roapEvent;
2656
- return _regenerator.default.wrap(function _callee50$(_context50) {
2657
- while (1) switch (_context50.prev = _context50.next) {
2889
+ return _regenerator.default.wrap(function _callee56$(_context56) {
2890
+ while (1) switch (_context56.prev = _context56.next) {
2658
2891
  case 0:
2659
2892
  expect.assertions(7);
2660
2893
  responsePayload = {
@@ -2667,25 +2900,25 @@ describe('Supplementary Services tests', function () {
2667
2900
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2668
2901
  call['held'] = true;
2669
2902
  call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
2670
- var _ref50 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49(correlationId) {
2671
- return _regenerator.default.wrap(function _callee49$(_context49) {
2672
- while (1) switch (_context49.prev = _context49.next) {
2903
+ var _ref56 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55(correlationId) {
2904
+ return _regenerator.default.wrap(function _callee55$(_context55) {
2905
+ while (1) switch (_context55.prev = _context55.next) {
2673
2906
  case 0:
2674
2907
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2675
2908
  case 1:
2676
2909
  case "end":
2677
- return _context49.stop();
2910
+ return _context55.stop();
2678
2911
  }
2679
- }, _callee49);
2912
+ }, _callee55);
2680
2913
  }));
2681
2914
  return function (_x6) {
2682
- return _ref50.apply(this, arguments);
2915
+ return _ref56.apply(this, arguments);
2683
2916
  };
2684
2917
  }());
2685
- _context50.next = 10;
2918
+ _context56.next = 10;
2686
2919
  return call.doHoldResume();
2687
2920
  case 10:
2688
- _context50.next = 12;
2921
+ _context56.next = 12;
2689
2922
  return (0, _testUtil.flushPromises)(2);
2690
2923
  case 12:
2691
2924
  expect(setTimeout).toHaveBeenCalledTimes(1);
@@ -2701,11 +2934,11 @@ describe('Supplementary Services tests', function () {
2701
2934
  call['handleIncomingRoapOffer']({}, dummyEvent);
2702
2935
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2703
2936
  roapEvent.data.type = 'ANSWER';
2704
- _context50.next = 20;
2937
+ _context56.next = 20;
2705
2938
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2706
2939
  case 20:
2707
2940
  roapEvent.data.type = 'OK';
2708
- _context50.next = 23;
2941
+ _context56.next = 23;
2709
2942
  return call['handleRoapEstablished']({}, dummyEvent);
2710
2943
  case 23:
2711
2944
  expect(clearTimeout).toHaveBeenCalledTimes(1);
@@ -2720,14 +2953,14 @@ describe('Supplementary Services tests', function () {
2720
2953
  });
2721
2954
  case 28:
2722
2955
  case "end":
2723
- return _context50.stop();
2956
+ return _context56.stop();
2724
2957
  }
2725
- }, _callee50);
2958
+ }, _callee56);
2726
2959
  })));
2727
- it('Handle successful Call Resume case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
2960
+ it('Handle successful Call Resume case with delayed http response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
2728
2961
  var responsePayload, warnSpy, roapEvent;
2729
- return _regenerator.default.wrap(function _callee52$(_context52) {
2730
- while (1) switch (_context52.prev = _context52.next) {
2962
+ return _regenerator.default.wrap(function _callee58$(_context58) {
2963
+ while (1) switch (_context58.prev = _context58.next) {
2731
2964
  case 0:
2732
2965
  expect.assertions(7);
2733
2966
  responsePayload = {
@@ -2740,26 +2973,26 @@ describe('Supplementary Services tests', function () {
2740
2973
  warnSpy = jest.spyOn(_Logger.default, 'warn');
2741
2974
  call['held'] = true;
2742
2975
  call.on(_types2.CALL_EVENT_KEYS.RESUMED, /*#__PURE__*/function () {
2743
- var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51(correlationId) {
2744
- return _regenerator.default.wrap(function _callee51$(_context51) {
2745
- while (1) switch (_context51.prev = _context51.next) {
2976
+ var _ref58 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57(correlationId) {
2977
+ return _regenerator.default.wrap(function _callee57$(_context57) {
2978
+ while (1) switch (_context57.prev = _context57.next) {
2746
2979
  case 0:
2747
2980
  expect(correlationId).toStrictEqual(call.getCorrelationId());
2748
2981
  case 1:
2749
2982
  case "end":
2750
- return _context51.stop();
2983
+ return _context57.stop();
2751
2984
  }
2752
- }, _callee51);
2985
+ }, _callee57);
2753
2986
  }));
2754
2987
  return function (_x7) {
2755
- return _ref52.apply(this, arguments);
2988
+ return _ref58.apply(this, arguments);
2756
2989
  };
2757
2990
  }());
2758
2991
  call.doHoldResume();
2759
- _context52.next = 11;
2992
+ _context58.next = 11;
2760
2993
  return _promise.default.resolve();
2761
2994
  case 11:
2762
- _context52.next = 13;
2995
+ _context58.next = 13;
2763
2996
  return _promise.default.resolve();
2764
2997
  case 13:
2765
2998
  expect(setTimeout).not.toHaveBeenCalled();
@@ -2775,11 +3008,11 @@ describe('Supplementary Services tests', function () {
2775
3008
  call['handleIncomingRoapOffer']({}, dummyEvent);
2776
3009
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2777
3010
  roapEvent.data.type = 'ANSWER';
2778
- _context52.next = 21;
3011
+ _context58.next = 21;
2779
3012
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2780
3013
  case 21:
2781
3014
  roapEvent.data.type = 'OK';
2782
- _context52.next = 24;
3015
+ _context58.next = 24;
2783
3016
  return call['handleRoapEstablished']({}, dummyEvent);
2784
3017
  case 24:
2785
3018
  expect(clearTimeout).not.toHaveBeenCalled();
@@ -2794,14 +3027,14 @@ describe('Supplementary Services tests', function () {
2794
3027
  });
2795
3028
  case 29:
2796
3029
  case "end":
2797
- return _context52.stop();
3030
+ return _context58.stop();
2798
3031
  }
2799
- }, _callee52);
3032
+ }, _callee58);
2800
3033
  })));
2801
- it('Handle failure Call Resume case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
3034
+ it('Handle failure Call Resume case during signalling', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60() {
2802
3035
  var responsePayload;
2803
- return _regenerator.default.wrap(function _callee54$(_context54) {
2804
- while (1) switch (_context54.prev = _context54.next) {
3036
+ return _regenerator.default.wrap(function _callee60$(_context60) {
3037
+ while (1) switch (_context60.prev = _context60.next) {
2805
3038
  case 0:
2806
3039
  expect.assertions(4);
2807
3040
  responsePayload = {
@@ -2811,26 +3044,26 @@ describe('Supplementary Services tests', function () {
2811
3044
  jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
2812
3045
  call['held'] = true;
2813
3046
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
2814
- var _ref54 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53(errObj) {
2815
- return _regenerator.default.wrap(function _callee53$(_context53) {
2816
- while (1) switch (_context53.prev = _context53.next) {
3047
+ var _ref60 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59(errObj) {
3048
+ return _regenerator.default.wrap(function _callee59$(_context59) {
3049
+ while (1) switch (_context59.prev = _context59.next) {
2817
3050
  case 0:
2818
3051
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2819
3052
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2820
3053
  case 2:
2821
3054
  case "end":
2822
- return _context53.stop();
3055
+ return _context59.stop();
2823
3056
  }
2824
- }, _callee53);
3057
+ }, _callee59);
2825
3058
  }));
2826
3059
  return function (_x8) {
2827
- return _ref54.apply(this, arguments);
3060
+ return _ref60.apply(this, arguments);
2828
3061
  };
2829
3062
  }());
2830
- _context54.next = 7;
3063
+ _context60.next = 7;
2831
3064
  return call.doHoldResume();
2832
3065
  case 7:
2833
- _context54.next = 9;
3066
+ _context60.next = 9;
2834
3067
  return (0, _testUtil.flushPromises)(2);
2835
3068
  case 9:
2836
3069
  expect(call.isHeld()).toStrictEqual(true);
@@ -2841,14 +3074,14 @@ describe('Supplementary Services tests', function () {
2841
3074
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2842
3075
  case 11:
2843
3076
  case "end":
2844
- return _context54.stop();
3077
+ return _context60.stop();
2845
3078
  }
2846
- }, _callee54);
3079
+ }, _callee60);
2847
3080
  })));
2848
- it('Handle failure Call Resume case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
3081
+ it('Handle failure Call Resume case during offer/answer exchange', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62() {
2849
3082
  var responsePayload, rejectPayload, roapEvent;
2850
- return _regenerator.default.wrap(function _callee56$(_context56) {
2851
- while (1) switch (_context56.prev = _context56.next) {
3083
+ return _regenerator.default.wrap(function _callee62$(_context62) {
3084
+ while (1) switch (_context62.prev = _context62.next) {
2852
3085
  case 0:
2853
3086
  expect.assertions(5);
2854
3087
  responsePayload = {
@@ -2862,24 +3095,24 @@ describe('Supplementary Services tests', function () {
2862
3095
  jest.spyOn(webex, 'request').mockResolvedValueOnce(responsePayload).mockRejectedValueOnce(rejectPayload);
2863
3096
  call['held'] = true;
2864
3097
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
2865
- var _ref56 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55(errObj) {
2866
- return _regenerator.default.wrap(function _callee55$(_context55) {
2867
- while (1) switch (_context55.prev = _context55.next) {
3098
+ var _ref62 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61(errObj) {
3099
+ return _regenerator.default.wrap(function _callee61$(_context61) {
3100
+ while (1) switch (_context61.prev = _context61.next) {
2868
3101
  case 0:
2869
3102
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.SERVICE_UNAVAILABLE);
2870
3103
  expect(errObj.message).toStrictEqual('An unknown error occurred. Wait a moment and try again.');
2871
3104
  case 2:
2872
3105
  case "end":
2873
- return _context55.stop();
3106
+ return _context61.stop();
2874
3107
  }
2875
- }, _callee55);
3108
+ }, _callee61);
2876
3109
  }));
2877
3110
  return function (_x9) {
2878
- return _ref56.apply(this, arguments);
3111
+ return _ref62.apply(this, arguments);
2879
3112
  };
2880
3113
  }());
2881
3114
  call.doHoldResume();
2882
- _context56.next = 9;
3115
+ _context62.next = 9;
2883
3116
  return (0, _testUtil.flushPromises)(2);
2884
3117
  case 9:
2885
3118
  /* At this point , the Call State should transition to S_CALL_ESTABLISHED
@@ -2890,7 +3123,7 @@ describe('Supplementary Services tests', function () {
2890
3123
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2891
3124
  /* We are intentionally failing the ROAP ANSWER */
2892
3125
  roapEvent.data.type = 'ANSWER';
2893
- _context56.next = 15;
3126
+ _context62.next = 15;
2894
3127
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2895
3128
  case 15:
2896
3129
  expect(call.isHeld()).toStrictEqual(true);
@@ -2898,14 +3131,14 @@ describe('Supplementary Services tests', function () {
2898
3131
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2899
3132
  case 17:
2900
3133
  case "end":
2901
- return _context56.stop();
3134
+ return _context62.stop();
2902
3135
  }
2903
- }, _callee56);
3136
+ }, _callee62);
2904
3137
  })));
2905
- it('Handle Call resume case where successful response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
3138
+ it('Handle Call resume case where successful response does not come', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
2906
3139
  var responsePayload, roapEvent;
2907
- return _regenerator.default.wrap(function _callee58$(_context58) {
2908
- while (1) switch (_context58.prev = _context58.next) {
3140
+ return _regenerator.default.wrap(function _callee64$(_context64) {
3141
+ while (1) switch (_context64.prev = _context64.next) {
2909
3142
  case 0:
2910
3143
  expect.assertions(5);
2911
3144
  responsePayload = {
@@ -2915,24 +3148,24 @@ describe('Supplementary Services tests', function () {
2915
3148
  jest.spyOn(webex, 'request').mockResolvedValue(responsePayload);
2916
3149
  call['held'] = true;
2917
3150
  call.on(_types2.CALL_EVENT_KEYS.RESUME_ERROR, /*#__PURE__*/function () {
2918
- var _ref58 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57(errObj) {
2919
- return _regenerator.default.wrap(function _callee57$(_context57) {
2920
- while (1) switch (_context57.prev = _context57.next) {
3151
+ var _ref64 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63(errObj) {
3152
+ return _regenerator.default.wrap(function _callee63$(_context63) {
3153
+ while (1) switch (_context63.prev = _context63.next) {
2921
3154
  case 0:
2922
3155
  expect(errObj.type).toStrictEqual(_types.ERROR_TYPE.TIMEOUT);
2923
3156
  expect(errObj.message).toStrictEqual('An error occurred while resuming the call. Wait a moment and try again.');
2924
3157
  case 2:
2925
3158
  case "end":
2926
- return _context57.stop();
3159
+ return _context63.stop();
2927
3160
  }
2928
- }, _callee57);
3161
+ }, _callee63);
2929
3162
  }));
2930
3163
  return function (_x0) {
2931
- return _ref58.apply(this, arguments);
3164
+ return _ref64.apply(this, arguments);
2932
3165
  };
2933
3166
  }());
2934
3167
  call.doHoldResume();
2935
- _context58.next = 8;
3168
+ _context64.next = 8;
2936
3169
  return (0, _testUtil.flushPromises)(2);
2937
3170
  case 8:
2938
3171
  /* At this point ,the Call State should be S_CALL_RESUME
@@ -2945,11 +3178,11 @@ describe('Supplementary Services tests', function () {
2945
3178
  call['handleIncomingRoapOffer']({}, dummyEvent);
2946
3179
  roapEvent = JSON.parse((0, _stringify.default)(dummyEvent));
2947
3180
  roapEvent.data.type = 'ANSWER';
2948
- _context58.next = 14;
3181
+ _context64.next = 14;
2949
3182
  return call['handleOutgoingRoapAnswer']({}, dummyEvent);
2950
3183
  case 14:
2951
3184
  roapEvent.data.type = 'OK';
2952
- _context58.next = 17;
3185
+ _context64.next = 17;
2953
3186
  return call['handleRoapEstablished']({}, dummyEvent);
2954
3187
  case 17:
2955
3188
  /* Advancing timer by 12 seconds so that it gets timed out */
@@ -2959,9 +3192,9 @@ describe('Supplementary Services tests', function () {
2959
3192
  expect(call['callStateMachine'].state.value).toStrictEqual('S_CALL_ESTABLISHED');
2960
3193
  case 20:
2961
3194
  case "end":
2962
- return _context58.stop();
3195
+ return _context64.stop();
2963
3196
  }
2964
- }, _callee58);
3197
+ }, _callee64);
2965
3198
  })));
2966
3199
  });
2967
3200
  describe('Call transfer tests', function () {
@@ -2994,10 +3227,10 @@ describe('Supplementary Services tests', function () {
2994
3227
  secondCall.removeAllListeners(_types2.CALL_EVENT_KEYS.CALL_ERROR);
2995
3228
  secondCall['held'] = false;
2996
3229
  });
2997
- it('Handle successful consult transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61() {
3230
+ it('Handle successful consult transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee67() {
2998
3231
  var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
2999
- return _regenerator.default.wrap(function _callee61$(_context61) {
3000
- while (1) switch (_context61.prev = _context61.next) {
3232
+ return _regenerator.default.wrap(function _callee67$(_context67) {
3233
+ while (1) switch (_context67.prev = _context67.next) {
3001
3234
  case 0:
3002
3235
  expect.assertions(12); // Updated to match actual assertion count
3003
3236
  responsePayload = {
@@ -3009,41 +3242,41 @@ describe('Supplementary Services tests', function () {
3009
3242
  infoSpy = jest.spyOn(_Logger.default, 'info');
3010
3243
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3011
3244
  call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3012
- var _ref60 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59(correlationId) {
3013
- return _regenerator.default.wrap(function _callee59$(_context59) {
3014
- while (1) switch (_context59.prev = _context59.next) {
3245
+ var _ref66 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee65(correlationId) {
3246
+ return _regenerator.default.wrap(function _callee65$(_context65) {
3247
+ while (1) switch (_context65.prev = _context65.next) {
3015
3248
  case 0:
3016
3249
  expect(correlationId).toStrictEqual(call.getCorrelationId());
3017
3250
  case 1:
3018
3251
  case "end":
3019
- return _context59.stop();
3252
+ return _context65.stop();
3020
3253
  }
3021
- }, _callee59);
3254
+ }, _callee65);
3022
3255
  }));
3023
3256
  return function (_x1) {
3024
- return _ref60.apply(this, arguments);
3257
+ return _ref66.apply(this, arguments);
3025
3258
  };
3026
3259
  }());
3027
3260
  secondCall.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3028
- var _ref61 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60(correlationId) {
3029
- return _regenerator.default.wrap(function _callee60$(_context60) {
3030
- while (1) switch (_context60.prev = _context60.next) {
3261
+ var _ref67 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee66(correlationId) {
3262
+ return _regenerator.default.wrap(function _callee66$(_context66) {
3263
+ while (1) switch (_context66.prev = _context66.next) {
3031
3264
  case 0:
3032
3265
  expect(correlationId).toStrictEqual(secondCall.getCorrelationId());
3033
3266
  case 1:
3034
3267
  case "end":
3035
- return _context60.stop();
3268
+ return _context66.stop();
3036
3269
  }
3037
- }, _callee60);
3270
+ }, _callee66);
3038
3271
  }));
3039
3272
  return function (_x10) {
3040
- return _ref61.apply(this, arguments);
3273
+ return _ref67.apply(this, arguments);
3041
3274
  };
3042
3275
  }());
3043
- _context61.next = 10;
3276
+ _context67.next = 10;
3044
3277
  return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
3045
3278
  case 10:
3046
- _context61.next = 12;
3279
+ _context67.next = 12;
3047
3280
  return (0, _testUtil.flushPromises)(2);
3048
3281
  case 12:
3049
3282
  expect(requestSpy).toBeCalled();
@@ -3066,14 +3299,14 @@ describe('Supplementary Services tests', function () {
3066
3299
  expect(warnSpy).not.toHaveBeenCalledWith("Consult Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
3067
3300
  case 24:
3068
3301
  case "end":
3069
- return _context61.stop();
3302
+ return _context67.stop();
3070
3303
  }
3071
- }, _callee61);
3304
+ }, _callee67);
3072
3305
  })));
3073
- it('Handle successful blind transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63() {
3306
+ it('Handle successful blind transfer case ', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee69() {
3074
3307
  var responsePayload, requestSpy, warnSpy, infoSpy, metricSpy;
3075
- return _regenerator.default.wrap(function _callee63$(_context63) {
3076
- while (1) switch (_context63.prev = _context63.next) {
3308
+ return _regenerator.default.wrap(function _callee69$(_context69) {
3309
+ while (1) switch (_context69.prev = _context69.next) {
3077
3310
  case 0:
3078
3311
  expect.assertions(10); // Updated to match actual assertion count
3079
3312
  responsePayload = {
@@ -3085,25 +3318,25 @@ describe('Supplementary Services tests', function () {
3085
3318
  infoSpy = jest.spyOn(_Logger.default, 'info');
3086
3319
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3087
3320
  call.on(_types2.CALL_EVENT_KEYS.DISCONNECT, /*#__PURE__*/function () {
3088
- var _ref63 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62(correlationId) {
3089
- return _regenerator.default.wrap(function _callee62$(_context62) {
3090
- while (1) switch (_context62.prev = _context62.next) {
3321
+ var _ref69 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee68(correlationId) {
3322
+ return _regenerator.default.wrap(function _callee68$(_context68) {
3323
+ while (1) switch (_context68.prev = _context68.next) {
3091
3324
  case 0:
3092
3325
  expect(correlationId).toStrictEqual(call.getCorrelationId());
3093
3326
  case 1:
3094
3327
  case "end":
3095
- return _context62.stop();
3328
+ return _context68.stop();
3096
3329
  }
3097
- }, _callee62);
3330
+ }, _callee68);
3098
3331
  }));
3099
3332
  return function (_x11) {
3100
- return _ref63.apply(this, arguments);
3333
+ return _ref69.apply(this, arguments);
3101
3334
  };
3102
3335
  }());
3103
- _context63.next = 9;
3336
+ _context69.next = 9;
3104
3337
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
3105
3338
  case 9:
3106
- _context63.next = 11;
3339
+ _context69.next = 11;
3107
3340
  return (0, _testUtil.flushPromises)(2);
3108
3341
  case 11:
3109
3342
  expect(requestSpy).toBeCalled();
@@ -3122,14 +3355,14 @@ describe('Supplementary Services tests', function () {
3122
3355
  expect(warnSpy).not.toHaveBeenCalledWith("Blind Transfer failed for correlationId ".concat(call.getCorrelationId()), transferLoggingContext);
3123
3356
  case 21:
3124
3357
  case "end":
3125
- return _context63.stop();
3358
+ return _context69.stop();
3126
3359
  }
3127
- }, _callee63);
3360
+ }, _callee69);
3128
3361
  })));
3129
- it('Handle unsuccessful blind transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
3362
+ it('Handle unsuccessful blind transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee70() {
3130
3363
  var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
3131
- return _regenerator.default.wrap(function _callee64$(_context64) {
3132
- while (1) switch (_context64.prev = _context64.next) {
3364
+ return _regenerator.default.wrap(function _callee70$(_context70) {
3365
+ while (1) switch (_context70.prev = _context70.next) {
3133
3366
  case 0:
3134
3367
  responsePayload = {
3135
3368
  statusCode: 403,
@@ -3140,10 +3373,10 @@ describe('Supplementary Services tests', function () {
3140
3373
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3141
3374
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3142
3375
  call['broadworksCorrelationInfo'] = 'dummy-broadworks-correlation-info';
3143
- _context64.next = 8;
3376
+ _context70.next = 8;
3144
3377
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, transfereeNumber);
3145
3378
  case 8:
3146
- _context64.next = 10;
3379
+ _context70.next = 10;
3147
3380
  return (0, _testUtil.flushPromises)(1);
3148
3381
  case 10:
3149
3382
  expect(requestSpy).toBeCalled();
@@ -3164,14 +3397,14 @@ describe('Supplementary Services tests', function () {
3164
3397
  expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.BLIND, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
3165
3398
  case 18:
3166
3399
  case "end":
3167
- return _context64.stop();
3400
+ return _context70.stop();
3168
3401
  }
3169
- }, _callee64);
3402
+ }, _callee70);
3170
3403
  })));
3171
- it('Handle unsuccessful consult transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee65() {
3404
+ it('Handle unsuccessful consult transfer case', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee71() {
3172
3405
  var responsePayload, emitSpy, requestSpy, warnSpy, metricSpy;
3173
- return _regenerator.default.wrap(function _callee65$(_context65) {
3174
- while (1) switch (_context65.prev = _context65.next) {
3406
+ return _regenerator.default.wrap(function _callee71$(_context71) {
3407
+ while (1) switch (_context71.prev = _context71.next) {
3175
3408
  case 0:
3176
3409
  responsePayload = {
3177
3410
  statusCode: 403,
@@ -3181,10 +3414,10 @@ describe('Supplementary Services tests', function () {
3181
3414
  requestSpy = jest.spyOn(webex, 'request').mockRejectedValue(responsePayload);
3182
3415
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3183
3416
  metricSpy = jest.spyOn(call['metricManager'], 'submitCallMetric');
3184
- _context65.next = 7;
3417
+ _context71.next = 7;
3185
3418
  return call.completeTransfer(_types5.TransferType.CONSULT, secondCall.getCallId(), undefined);
3186
3419
  case 7:
3187
- _context65.next = 9;
3420
+ _context71.next = 9;
3188
3421
  return (0, _testUtil.flushPromises)(2);
3189
3422
  case 9:
3190
3423
  expect(requestSpy).toBeCalled();
@@ -3205,18 +3438,18 @@ describe('Supplementary Services tests', function () {
3205
3438
  expect(metricSpy).toHaveBeenCalledWith(_types4.METRIC_EVENT.CALL_ERROR, _types4.TRANSFER_ACTION.CONSULT, _types4.METRIC_TYPE.BEHAVIORAL, call.getCallId(), call.getCorrelationId(), expect.any(_Errors.CallError));
3206
3439
  case 18:
3207
3440
  case "end":
3208
- return _context65.stop();
3441
+ return _context71.stop();
3209
3442
  }
3210
- }, _callee65);
3443
+ }, _callee71);
3211
3444
  })));
3212
- it('Handle blind transfer with undefined transferTarget', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee66() {
3445
+ it('Handle blind transfer with undefined transferTarget', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee72() {
3213
3446
  var requestSpy, warnSpy;
3214
- return _regenerator.default.wrap(function _callee66$(_context66) {
3215
- while (1) switch (_context66.prev = _context66.next) {
3447
+ return _regenerator.default.wrap(function _callee72$(_context72) {
3448
+ while (1) switch (_context72.prev = _context72.next) {
3216
3449
  case 0:
3217
3450
  requestSpy = jest.spyOn(webex, 'request');
3218
3451
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3219
- _context66.next = 4;
3452
+ _context72.next = 4;
3220
3453
  return call.completeTransfer(_types5.TransferType.BLIND, undefined, undefined);
3221
3454
  case 4:
3222
3455
  /* We should be in CALL_ESTABLISHED state */
@@ -3228,18 +3461,18 @@ describe('Supplementary Services tests', function () {
3228
3461
  expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
3229
3462
  case 10:
3230
3463
  case "end":
3231
- return _context66.stop();
3464
+ return _context72.stop();
3232
3465
  }
3233
- }, _callee66);
3466
+ }, _callee72);
3234
3467
  })));
3235
- it('Handle consult transfer with undefined transferCallId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee67() {
3468
+ it('Handle consult transfer with undefined transferCallId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee73() {
3236
3469
  var requestSpy, warnSpy;
3237
- return _regenerator.default.wrap(function _callee67$(_context67) {
3238
- while (1) switch (_context67.prev = _context67.next) {
3470
+ return _regenerator.default.wrap(function _callee73$(_context73) {
3471
+ while (1) switch (_context73.prev = _context73.next) {
3239
3472
  case 0:
3240
3473
  requestSpy = jest.spyOn(webex, 'request');
3241
3474
  warnSpy = jest.spyOn(_Logger.default, 'warn');
3242
- _context67.next = 4;
3475
+ _context73.next = 4;
3243
3476
  return call.completeTransfer(_types5.TransferType.CONSULT, undefined, undefined);
3244
3477
  case 4:
3245
3478
  /* We should be in CALL_ESTABLISHED state */
@@ -3251,9 +3484,9 @@ describe('Supplementary Services tests', function () {
3251
3484
  expect(warnSpy).toBeCalledOnceWith("Invalid information received, transfer failed for correlationId: ".concat(call.getCorrelationId()), transferLoggingContext);
3252
3485
  case 10:
3253
3486
  case "end":
3254
- return _context67.stop();
3487
+ return _context73.stop();
3255
3488
  }
3256
- }, _callee67);
3489
+ }, _callee73);
3257
3490
  })));
3258
3491
  });
3259
3492
  });