@webex/calling 3.0.0-next.2 → 3.0.0-next.4

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 (283) hide show
  1. package/CHANGELOG.md +1403 -0
  2. package/README.md +74 -74
  3. package/dist/module/CallHistory/CallHistory.js +81 -81
  4. package/dist/module/CallHistory/callHistoryFixtures.js +307 -307
  5. package/dist/module/CallHistory/constants.js +9 -9
  6. package/dist/module/CallHistory/types.js +1 -1
  7. package/dist/module/CallSettings/CallSettings.js +65 -65
  8. package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
  9. package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
  10. package/dist/module/CallSettings/constants.js +11 -11
  11. package/dist/module/CallSettings/testFixtures.js +62 -62
  12. package/dist/module/CallSettings/types.js +1 -1
  13. package/dist/module/CallingClient/CallingClient.js +248 -248
  14. package/dist/module/CallingClient/callRecordFixtures.js +93 -93
  15. package/dist/module/CallingClient/calling/CallerId/index.js +169 -169
  16. package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
  17. package/dist/module/CallingClient/calling/call.js +1658 -1658
  18. package/dist/module/CallingClient/calling/callManager.js +284 -284
  19. package/dist/module/CallingClient/calling/index.js +2 -2
  20. package/dist/module/CallingClient/calling/types.js +53 -53
  21. package/dist/module/CallingClient/callingClientFixtures.js +38 -38
  22. package/dist/module/CallingClient/constants.js +122 -122
  23. package/dist/module/CallingClient/line/index.js +158 -158
  24. package/dist/module/CallingClient/line/types.js +15 -15
  25. package/dist/module/CallingClient/registration/index.js +1 -1
  26. package/dist/module/CallingClient/registration/register.js +507 -507
  27. package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
  28. package/dist/module/CallingClient/registration/types.js +1 -1
  29. package/dist/module/CallingClient/types.js +1 -1
  30. package/dist/module/Contacts/ContactsClient.js +484 -484
  31. package/dist/module/Contacts/constants.js +20 -20
  32. package/dist/module/Contacts/contactFixtures.js +284 -284
  33. package/dist/module/Contacts/types.js +10 -10
  34. package/dist/module/Errors/catalog/CallError.js +26 -26
  35. package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
  36. package/dist/module/Errors/catalog/ExtendedError.js +10 -10
  37. package/dist/module/Errors/catalog/LineError.js +24 -24
  38. package/dist/module/Errors/index.js +2 -2
  39. package/dist/module/Errors/types.js +48 -48
  40. package/dist/module/Events/impl/index.js +19 -19
  41. package/dist/module/Events/types.js +83 -83
  42. package/dist/module/Logger/index.js +114 -114
  43. package/dist/module/Logger/types.js +25 -25
  44. package/dist/module/Metrics/index.js +232 -232
  45. package/dist/module/Metrics/types.js +37 -37
  46. package/dist/module/SDKConnector/index.js +39 -39
  47. package/dist/module/SDKConnector/types.js +1 -1
  48. package/dist/module/SDKConnector/utils.js +12 -12
  49. package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
  50. package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
  51. package/dist/module/Voicemail/Voicemail.js +110 -110
  52. package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
  53. package/dist/module/Voicemail/constants.js +29 -29
  54. package/dist/module/Voicemail/types.js +1 -1
  55. package/dist/module/Voicemail/voicemailFixture.js +510 -510
  56. package/dist/module/api.js +6 -6
  57. package/dist/module/common/Utils.js +802 -802
  58. package/dist/module/common/constants.js +41 -41
  59. package/dist/module/common/index.js +1 -1
  60. package/dist/module/common/testUtil.js +938 -938
  61. package/dist/module/common/types.js +57 -57
  62. package/dist/module/index.js +8 -8
  63. package/dist/types/CallHistory/CallHistory.d.ts +17 -17
  64. package/dist/types/CallHistory/callHistoryFixtures.d.ts +94 -94
  65. package/dist/types/CallHistory/constants.d.ts +9 -9
  66. package/dist/types/CallHistory/types.d.ts +18 -18
  67. package/dist/types/CallSettings/CallSettings.d.ts +19 -19
  68. package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
  69. package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
  70. package/dist/types/CallSettings/constants.d.ts +11 -11
  71. package/dist/types/CallSettings/testFixtures.d.ts +15 -15
  72. package/dist/types/CallSettings/types.d.ts +107 -107
  73. package/dist/types/CallingClient/CallingClient.d.ts +35 -35
  74. package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
  75. package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
  76. package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
  77. package/dist/types/CallingClient/calling/call.d.ts +96 -96
  78. package/dist/types/CallingClient/calling/callManager.d.ts +25 -25
  79. package/dist/types/CallingClient/calling/index.d.ts +2 -2
  80. package/dist/types/CallingClient/calling/types.d.ts +206 -206
  81. package/dist/types/CallingClient/callingClientFixtures.d.ts +18 -18
  82. package/dist/types/CallingClient/constants.d.ts +122 -122
  83. package/dist/types/CallingClient/line/index.d.ts +43 -43
  84. package/dist/types/CallingClient/line/types.d.ts +55 -55
  85. package/dist/types/CallingClient/registration/index.d.ts +1 -1
  86. package/dist/types/CallingClient/registration/register.d.ts +64 -64
  87. package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
  88. package/dist/types/CallingClient/registration/types.d.ts +20 -20
  89. package/dist/types/CallingClient/types.d.ts +29 -29
  90. package/dist/types/Contacts/ContactsClient.d.ts +26 -26
  91. package/dist/types/Contacts/constants.d.ts +19 -19
  92. package/dist/types/Contacts/contactFixtures.d.ts +280 -280
  93. package/dist/types/Contacts/types.d.ts +72 -72
  94. package/dist/types/Errors/catalog/CallError.d.ts +11 -11
  95. package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
  96. package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
  97. package/dist/types/Errors/catalog/LineError.d.ts +10 -10
  98. package/dist/types/Errors/index.d.ts +2 -2
  99. package/dist/types/Errors/types.d.ts +60 -60
  100. package/dist/types/Events/impl/index.d.ts +8 -8
  101. package/dist/types/Events/types.d.ts +288 -288
  102. package/dist/types/Logger/index.d.ts +12 -12
  103. package/dist/types/Logger/types.d.ts +25 -25
  104. package/dist/types/Metrics/index.d.ts +5 -5
  105. package/dist/types/Metrics/types.d.ts +42 -42
  106. package/dist/types/SDKConnector/index.d.ts +12 -12
  107. package/dist/types/SDKConnector/types.d.ts +128 -128
  108. package/dist/types/SDKConnector/utils.d.ts +5 -5
  109. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
  110. package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
  111. package/dist/types/Voicemail/Voicemail.d.ts +27 -27
  112. package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
  113. package/dist/types/Voicemail/constants.d.ts +29 -29
  114. package/dist/types/Voicemail/types.d.ts +133 -133
  115. package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
  116. package/dist/types/api.d.ts +16 -16
  117. package/dist/types/common/Utils.d.ts +34 -34
  118. package/dist/types/common/constants.d.ts +41 -41
  119. package/dist/types/common/index.d.ts +1 -1
  120. package/dist/types/common/testUtil.d.ts +3611 -3611
  121. package/dist/types/common/types.d.ts +191 -191
  122. package/dist/types/index.d.ts +8 -8
  123. package/package.json +4 -4
  124. package/dist/CallHistory/CallHistory.js +0 -203
  125. package/dist/CallHistory/CallHistory.js.map +0 -1
  126. package/dist/CallHistory/CallHistory.test.js +0 -133
  127. package/dist/CallHistory/CallHistory.test.js.map +0 -1
  128. package/dist/CallHistory/callHistoryFixtures.js +0 -310
  129. package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
  130. package/dist/CallHistory/constants.js +0 -26
  131. package/dist/CallHistory/constants.js.map +0 -1
  132. package/dist/CallHistory/types.js +0 -7
  133. package/dist/CallHistory/types.js.map +0 -1
  134. package/dist/CallSettings/CallSettings.js +0 -276
  135. package/dist/CallSettings/CallSettings.js.map +0 -1
  136. package/dist/CallSettings/CallSettings.test.js +0 -122
  137. package/dist/CallSettings/CallSettings.test.js.map +0 -1
  138. package/dist/CallSettings/UcmBackendConnector.js +0 -217
  139. package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
  140. package/dist/CallSettings/UcmBackendConnector.test.js +0 -227
  141. package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
  142. package/dist/CallSettings/WxCallBackendConnector.js +0 -541
  143. package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
  144. package/dist/CallSettings/WxCallBackendConnector.test.js +0 -802
  145. package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
  146. package/dist/CallSettings/constants.js +0 -30
  147. package/dist/CallSettings/constants.js.map +0 -1
  148. package/dist/CallSettings/testFixtures.js +0 -72
  149. package/dist/CallSettings/testFixtures.js.map +0 -1
  150. package/dist/CallSettings/types.js +0 -7
  151. package/dist/CallSettings/types.js.map +0 -1
  152. package/dist/CallingClient/CallingClient.js +0 -572
  153. package/dist/CallingClient/CallingClient.js.map +0 -1
  154. package/dist/CallingClient/CallingClient.test.js +0 -931
  155. package/dist/CallingClient/CallingClient.test.js.map +0 -1
  156. package/dist/CallingClient/callRecordFixtures.js +0 -103
  157. package/dist/CallingClient/callRecordFixtures.js.map +0 -1
  158. package/dist/CallingClient/calling/CallerId/index.js +0 -287
  159. package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
  160. package/dist/CallingClient/calling/CallerId/index.test.js +0 -274
  161. package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
  162. package/dist/CallingClient/calling/CallerId/types.js +0 -7
  163. package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
  164. package/dist/CallingClient/calling/call.js +0 -2995
  165. package/dist/CallingClient/calling/call.js.map +0 -1
  166. package/dist/CallingClient/calling/call.test.js +0 -2614
  167. package/dist/CallingClient/calling/call.test.js.map +0 -1
  168. package/dist/CallingClient/calling/callManager.js +0 -443
  169. package/dist/CallingClient/calling/callManager.js.map +0 -1
  170. package/dist/CallingClient/calling/callManager.test.js +0 -683
  171. package/dist/CallingClient/calling/callManager.test.js.map +0 -1
  172. package/dist/CallingClient/calling/index.js +0 -30
  173. package/dist/CallingClient/calling/index.js.map +0 -1
  174. package/dist/CallingClient/calling/types.js +0 -71
  175. package/dist/CallingClient/calling/types.js.map +0 -1
  176. package/dist/CallingClient/callingClientFixtures.js +0 -53
  177. package/dist/CallingClient/callingClientFixtures.js.map +0 -1
  178. package/dist/CallingClient/constants.js +0 -226
  179. package/dist/CallingClient/constants.js.map +0 -1
  180. package/dist/CallingClient/line/index.js +0 -312
  181. package/dist/CallingClient/line/index.js.map +0 -1
  182. package/dist/CallingClient/line/line.test.js +0 -270
  183. package/dist/CallingClient/line/line.test.js.map +0 -1
  184. package/dist/CallingClient/line/types.js +0 -25
  185. package/dist/CallingClient/line/types.js.map +0 -1
  186. package/dist/CallingClient/registration/index.js +0 -19
  187. package/dist/CallingClient/registration/index.js.map +0 -1
  188. package/dist/CallingClient/registration/register.js +0 -1295
  189. package/dist/CallingClient/registration/register.js.map +0 -1
  190. package/dist/CallingClient/registration/register.test.js +0 -838
  191. package/dist/CallingClient/registration/register.test.js.map +0 -1
  192. package/dist/CallingClient/registration/registerFixtures.js +0 -41
  193. package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
  194. package/dist/CallingClient/registration/types.js +0 -7
  195. package/dist/CallingClient/registration/types.js.map +0 -1
  196. package/dist/CallingClient/types.js +0 -7
  197. package/dist/CallingClient/types.js.map +0 -1
  198. package/dist/Contacts/ContactsClient.js +0 -1139
  199. package/dist/Contacts/ContactsClient.js.map +0 -1
  200. package/dist/Contacts/ContactsClient.test.js +0 -725
  201. package/dist/Contacts/ContactsClient.test.js.map +0 -1
  202. package/dist/Contacts/constants.js +0 -36
  203. package/dist/Contacts/constants.js.map +0 -1
  204. package/dist/Contacts/contactFixtures.js +0 -340
  205. package/dist/Contacts/contactFixtures.js.map +0 -1
  206. package/dist/Contacts/types.js +0 -20
  207. package/dist/Contacts/types.js.map +0 -1
  208. package/dist/Errors/catalog/CallError.js +0 -94
  209. package/dist/Errors/catalog/CallError.js.map +0 -1
  210. package/dist/Errors/catalog/CallingDeviceError.js +0 -88
  211. package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
  212. package/dist/Errors/catalog/ExtendedError.js +0 -45
  213. package/dist/Errors/catalog/ExtendedError.js.map +0 -1
  214. package/dist/Errors/catalog/LineError.js +0 -90
  215. package/dist/Errors/catalog/LineError.js.map +0 -1
  216. package/dist/Errors/index.js +0 -21
  217. package/dist/Errors/index.js.map +0 -1
  218. package/dist/Errors/types.js +0 -62
  219. package/dist/Errors/types.js.map +0 -1
  220. package/dist/Events/impl/index.js +0 -82
  221. package/dist/Events/impl/index.js.map +0 -1
  222. package/dist/Events/types.js +0 -111
  223. package/dist/Events/types.js.map +0 -1
  224. package/dist/Logger/index.js +0 -221
  225. package/dist/Logger/index.js.map +0 -1
  226. package/dist/Logger/index.test.js +0 -62
  227. package/dist/Logger/index.test.js.map +0 -1
  228. package/dist/Logger/types.js +0 -37
  229. package/dist/Logger/types.js.map +0 -1
  230. package/dist/Metrics/index.js +0 -329
  231. package/dist/Metrics/index.js.map +0 -1
  232. package/dist/Metrics/index.test.js +0 -291
  233. package/dist/Metrics/index.test.js.map +0 -1
  234. package/dist/Metrics/types.js +0 -50
  235. package/dist/Metrics/types.js.map +0 -1
  236. package/dist/SDKConnector/index.js +0 -105
  237. package/dist/SDKConnector/index.js.map +0 -1
  238. package/dist/SDKConnector/index.test.js +0 -9
  239. package/dist/SDKConnector/index.test.js.map +0 -1
  240. package/dist/SDKConnector/types.js +0 -7
  241. package/dist/SDKConnector/types.js.map +0 -1
  242. package/dist/SDKConnector/utils.js +0 -40
  243. package/dist/SDKConnector/utils.js.map +0 -1
  244. package/dist/SDKConnector/utils.test.js +0 -9
  245. package/dist/SDKConnector/utils.test.js.map +0 -1
  246. package/dist/Voicemail/BroadworksBackendConnector.js +0 -632
  247. package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
  248. package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -733
  249. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
  250. package/dist/Voicemail/UcmBackendConnector.js +0 -566
  251. package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
  252. package/dist/Voicemail/UcmBackendConnector.test.js +0 -628
  253. package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
  254. package/dist/Voicemail/Voicemail.js +0 -378
  255. package/dist/Voicemail/Voicemail.js.map +0 -1
  256. package/dist/Voicemail/Voicemail.test.js +0 -226
  257. package/dist/Voicemail/Voicemail.test.js.map +0 -1
  258. package/dist/Voicemail/WxCallBackendConnector.js +0 -540
  259. package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
  260. package/dist/Voicemail/WxCallBackendConnector.test.js +0 -942
  261. package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
  262. package/dist/Voicemail/constants.js +0 -66
  263. package/dist/Voicemail/constants.js.map +0 -1
  264. package/dist/Voicemail/types.js +0 -7
  265. package/dist/Voicemail/types.js.map +0 -1
  266. package/dist/Voicemail/voicemailFixture.js +0 -559
  267. package/dist/Voicemail/voicemailFixture.js.map +0 -1
  268. package/dist/api.js +0 -134
  269. package/dist/api.js.map +0 -1
  270. package/dist/common/Utils.js +0 -1264
  271. package/dist/common/Utils.js.map +0 -1
  272. package/dist/common/Utils.test.js +0 -1227
  273. package/dist/common/Utils.test.js.map +0 -1
  274. package/dist/common/constants.js +0 -90
  275. package/dist/common/constants.js.map +0 -1
  276. package/dist/common/index.js +0 -19
  277. package/dist/common/index.js.map +0 -1
  278. package/dist/common/testUtil.js +0 -968
  279. package/dist/common/testUtil.js.map +0 -1
  280. package/dist/common/types.js +0 -75
  281. package/dist/common/types.js.map +0 -1
  282. package/dist/index.js +0 -63
  283. package/dist/index.js.map +0 -1
@@ -1,931 +0,0 @@
1
- "use strict";
2
-
3
- var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
- var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
5
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
7
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
8
- var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
9
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
10
- var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
11
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
15
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
16
- var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
17
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
18
- var _asyncMutex = require("async-mutex");
19
- var _types = require("../Logger/types");
20
- var _testUtil = require("../common/testUtil");
21
- var _types2 = require("../common/types");
22
- var _types3 = require("../Events/types");
23
- var _Logger = _interopRequireDefault(require("../Logger"));
24
- var _CallingClient = require("./CallingClient");
25
- var utils = _interopRequireWildcard(require("../common/Utils"));
26
- var _callManager = require("./calling/callManager");
27
- var _constants = require("./constants");
28
- var _callRecordFixtures = require("./callRecordFixtures");
29
- var _types4 = require("./line/types");
30
- var _callingClientFixtures = require("./callingClientFixtures");
31
- var _line = _interopRequireDefault(require("./line"));
32
- var _registerFixtures = require("./registration/registerFixtures");
33
- function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
34
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
37
- describe('CallingClient Tests', function () {
38
- // Common initializers
39
-
40
- var handleErrorSpy = jest.spyOn(utils, 'handleCallingClientErrors');
41
- var webex = (0, _testUtil.getTestUtilsWebex)();
42
- var defaultServiceIndicator = _types2.ServiceIndicator.CALLING;
43
- var callManager = (0, _callManager.getCallManager)(webex, defaultServiceIndicator);
44
- var logSpy = jest.spyOn(_Logger.default, 'info');
45
- var warnSpy = jest.spyOn(_Logger.default, 'warn');
46
- var originalProcessNextTick = process.nextTick;
47
- function flushPromises() {
48
- return new _promise.default(function (resolve) {
49
- originalProcessNextTick(resolve);
50
- });
51
- }
52
- describe('ServiceData tests', function () {
53
- var callingClient;
54
- afterEach(function () {
55
- callManager.removeAllListeners();
56
- callingClient = undefined;
57
- });
58
-
59
- /**
60
- * No input sdk config to callingClient, it should default to service type
61
- * calling and empty domain value.
62
- */
63
- it('Verify valid calling serviceData with no input sdk config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
64
- return _regenerator.default.wrap(function _callee2$(_context2) {
65
- while (1) switch (_context2.prev = _context2.next) {
66
- case 0:
67
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
68
- return _regenerator.default.wrap(function _callee$(_context) {
69
- while (1) switch (_context.prev = _context.next) {
70
- case 0:
71
- _context.next = 2;
72
- return (0, _CallingClient.createClient)(webex);
73
- case 2:
74
- callingClient = _context.sent;
75
- expect(callingClient).toBeTruthy();
76
- case 4:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }))).not.toThrow(Error);
82
- case 1:
83
- case "end":
84
- return _context2.stop();
85
- }
86
- }, _callee2);
87
- })));
88
-
89
- /**
90
- * Input sdk config to callingClient with serviceData carrying empty string for
91
- * both indicator and domain in it.
92
- *
93
- * It should default to service type calling and empty domain value.
94
- *
95
- */
96
- it('Verify invalid empty service indicator, empty domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
97
- var serviceDataObj;
98
- return _regenerator.default.wrap(function _callee4$(_context4) {
99
- while (1) switch (_context4.prev = _context4.next) {
100
- case 0:
101
- /* eslint-disable @typescript-eslint/no-explicit-any */
102
- serviceDataObj = {
103
- indicator: '',
104
- domain: ''
105
- };
106
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
107
- return _regenerator.default.wrap(function _callee3$(_context3) {
108
- while (1) switch (_context3.prev = _context3.next) {
109
- case 0:
110
- _context3.next = 2;
111
- return (0, _CallingClient.createClient)(webex, {
112
- serviceData: serviceDataObj
113
- });
114
- case 2:
115
- callingClient = _context3.sent;
116
- expect(callingClient).toBeTruthy();
117
- case 4:
118
- case "end":
119
- return _context3.stop();
120
- }
121
- }, _callee3);
122
- }))).not.toThrow(Error);
123
- case 2:
124
- case "end":
125
- return _context4.stop();
126
- }
127
- }, _callee4);
128
- })));
129
-
130
- /**
131
- * Input sdk config to callingClient with serviceData carrying invalid value for indicator
132
- * and valid domain type string for domain field in it.
133
- *
134
- * It should throw error and abort execution as indicator value is invalid.
135
- *
136
- * INDICATOR value MUST MATCH with one of the values in ServiceIndicator enum.
137
- */
138
- it('Verify invalid service indicator, valid domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
139
- var serviceDataObj;
140
- return _regenerator.default.wrap(function _callee5$(_context5) {
141
- while (1) switch (_context5.prev = _context5.next) {
142
- case 0:
143
- /* eslint-disable @typescript-eslint/no-explicit-any */
144
- serviceDataObj = {
145
- indicator: 'test',
146
- domain: 'test.example.com'
147
- };
148
- _context5.prev = 1;
149
- _context5.next = 4;
150
- return (0, _CallingClient.createClient)(webex, {
151
- serviceData: serviceDataObj
152
- });
153
- case 4:
154
- callingClient = _context5.sent;
155
- _context5.next = 10;
156
- break;
157
- case 7:
158
- _context5.prev = 7;
159
- _context5.t0 = _context5["catch"](1);
160
- expect(_context5.t0.message).toEqual('Invalid service indicator, Allowed values are: calling,contactcenter');
161
- case 10:
162
- expect.assertions(1);
163
- case 11:
164
- case "end":
165
- return _context5.stop();
166
- }
167
- }, _callee5, null, [[1, 7]]);
168
- })));
169
-
170
- /**
171
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
172
- * 'calling', but an invalid domain type string for domain field in it.
173
- *
174
- * It should throw error and abort execution as domain value is invalid.
175
- *
176
- * DOMAIN field for service type calling is allowed to be empty but if it carries a non-empty
177
- * string then it must be of valid domain type.
178
- */
179
- it('CALLING: verify invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
180
- var serviceDataObj;
181
- return _regenerator.default.wrap(function _callee6$(_context6) {
182
- while (1) switch (_context6.prev = _context6.next) {
183
- case 0:
184
- serviceDataObj = {
185
- indicator: _types2.ServiceIndicator.CALLING,
186
- domain: 'test'
187
- };
188
- _context6.prev = 1;
189
- _context6.next = 4;
190
- return (0, _CallingClient.createClient)(webex, {
191
- serviceData: serviceDataObj
192
- });
193
- case 4:
194
- callingClient = _context6.sent;
195
- _context6.next = 10;
196
- break;
197
- case 7:
198
- _context6.prev = 7;
199
- _context6.t0 = _context6["catch"](1);
200
- expect(_context6.t0.message).toEqual('Invalid service domain.');
201
- case 10:
202
- expect.assertions(1);
203
- case 11:
204
- case "end":
205
- return _context6.stop();
206
- }
207
- }, _callee6, null, [[1, 7]]);
208
- })));
209
-
210
- /**
211
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
212
- * 'calling', and an empty string for domain field in it.
213
- *
214
- * Execution should proceed properly and createRegistration should be called with same serviceData.
215
- *
216
- * DOMAIN field for service type 'calling' is allowed to be empty.
217
- */
218
- it('CALLING: verify valid empty service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
219
- var serviceDataObj;
220
- return _regenerator.default.wrap(function _callee8$(_context8) {
221
- while (1) switch (_context8.prev = _context8.next) {
222
- case 0:
223
- serviceDataObj = {
224
- indicator: _types2.ServiceIndicator.CALLING,
225
- domain: ''
226
- };
227
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
228
- return _regenerator.default.wrap(function _callee7$(_context7) {
229
- while (1) switch (_context7.prev = _context7.next) {
230
- case 0:
231
- _context7.next = 2;
232
- return (0, _CallingClient.createClient)(webex, {
233
- serviceData: serviceDataObj
234
- });
235
- case 2:
236
- callingClient = _context7.sent;
237
- expect(callingClient).toBeTruthy();
238
- case 4:
239
- case "end":
240
- return _context7.stop();
241
- }
242
- }, _callee7);
243
- }))).not.toThrow(Error);
244
- case 2:
245
- case "end":
246
- return _context8.stop();
247
- }
248
- }, _callee8);
249
- })));
250
-
251
- /**
252
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
253
- * 'contactcenter', but an empty string for domain field in it.
254
- *
255
- * It should throw error and abort execution as domain value is invalid.
256
- *
257
- * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
258
- */
259
- it('ContactCenter: verify empty invalid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
260
- var serviceDataObj;
261
- return _regenerator.default.wrap(function _callee9$(_context9) {
262
- while (1) switch (_context9.prev = _context9.next) {
263
- case 0:
264
- serviceDataObj = {
265
- indicator: _types2.ServiceIndicator.CONTACT_CENTER,
266
- domain: ''
267
- };
268
- _context9.prev = 1;
269
- _context9.next = 4;
270
- return (0, _CallingClient.createClient)(webex, {
271
- serviceData: serviceDataObj
272
- });
273
- case 4:
274
- callingClient = _context9.sent;
275
- _context9.next = 10;
276
- break;
277
- case 7:
278
- _context9.prev = 7;
279
- _context9.t0 = _context9["catch"](1);
280
- expect(_context9.t0.message).toEqual('Invalid service domain.');
281
- case 10:
282
- expect.assertions(1);
283
- case 11:
284
- case "end":
285
- return _context9.stop();
286
- }
287
- }, _callee9, null, [[1, 7]]);
288
- })));
289
-
290
- /**
291
- * Input sdk config to callingClient with serviceData carrying valid value for indicator
292
- * 'contactcenter', and a valid domain type string for domain field in it.
293
- *
294
- * Execution should proceed properly and createRegistration should be called with same serviceData.
295
- *
296
- * DOMAIN field for service type 'contactcenter' must carry a non-empty valid domain type string.
297
- */
298
- it('ContactCenter: verify valid service domain', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
299
- var serviceDataObj;
300
- return _regenerator.default.wrap(function _callee11$(_context11) {
301
- while (1) switch (_context11.prev = _context11.next) {
302
- case 0:
303
- serviceDataObj = {
304
- indicator: _types2.ServiceIndicator.CONTACT_CENTER,
305
- domain: 'test.example.com'
306
- };
307
- expect( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
308
- return _regenerator.default.wrap(function _callee10$(_context10) {
309
- while (1) switch (_context10.prev = _context10.next) {
310
- case 0:
311
- _context10.next = 2;
312
- return (0, _CallingClient.createClient)(webex, {
313
- serviceData: serviceDataObj
314
- });
315
- case 2:
316
- callingClient = _context10.sent;
317
- expect(callingClient).toBeTruthy();
318
- case 4:
319
- case "end":
320
- return _context10.stop();
321
- }
322
- }, _callee10);
323
- }))).not.toThrow(Error);
324
- case 2:
325
- case "end":
326
- return _context11.stop();
327
- }
328
- }, _callee11);
329
- })));
330
- it('Get current log level', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
331
- return _regenerator.default.wrap(function _callee12$(_context12) {
332
- while (1) switch (_context12.prev = _context12.next) {
333
- case 0:
334
- _context12.next = 2;
335
- return (0, _CallingClient.createClient)(webex, {
336
- logger: {
337
- level: _types.LOGGER.INFO
338
- }
339
- });
340
- case 2:
341
- callingClient = _context12.sent;
342
- expect(callingClient).toBeTruthy();
343
- expect(callingClient.getLoggingLevel).toBeTruthy();
344
- expect(callingClient.getLoggingLevel()).toEqual(_types.LOGGER.INFO);
345
- case 6:
346
- case "end":
347
- return _context12.stop();
348
- }
349
- }, _callee12);
350
- })));
351
- });
352
- describe('Mobius Server discovery tests', function () {
353
- var callingClient;
354
- afterEach(function () {
355
- jest.clearAllTimers();
356
- jest.clearAllMocks();
357
- callingClient.removeAllListeners();
358
- callManager.removeAllListeners();
359
- callingClient = undefined;
360
- jest.useRealTimers();
361
- });
362
- it('verify successful mobius server url discovery', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
363
- return _regenerator.default.wrap(function _callee13$(_context13) {
364
- while (1) switch (_context13.prev = _context13.next) {
365
- case 0:
366
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
367
- _context13.next = 3;
368
- return (0, _CallingClient.createClient)(webex, {
369
- logger: {
370
- level: _types.LOGGER.INFO
371
- }
372
- });
373
- case 3:
374
- callingClient = _context13.sent;
375
- expect(webex.request).toBeCalledTimes(3);
376
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
377
- expect(handleErrorSpy).not.toBeCalled();
378
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({
379
- method: 'GET'
380
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
381
- uri: "".concat(_callingClientFixtures.uri, "myip")
382
- }));
383
- expect(webex.request).nthCalledWith(2, {
384
- method: 'GET',
385
- uri: "".concat(_constants.DISCOVERY_URL, "/").concat(_callingClientFixtures.myIP),
386
- addAuthHeader: false,
387
- headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
388
- });
389
- expect(webex.request).nthCalledWith(3, _objectSpread(_objectSpread({
390
- method: 'GET'
391
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
392
- uri: "".concat(_callingClientFixtures.uri, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode)
393
- }));
394
- case 10:
395
- case "end":
396
- return _context13.stop();
397
- }
398
- }, _callee13);
399
- })));
400
- it('case when region discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
401
- var failurePayload;
402
- return _regenerator.default.wrap(function _callee14$(_context14) {
403
- while (1) switch (_context14.prev = _context14.next) {
404
- case 0:
405
- failurePayload = {
406
- statusCode: 500
407
- };
408
- webex.request.mockRejectedValueOnce(failurePayload);
409
- _context14.next = 4;
410
- return (0, _CallingClient.createClient)(webex, {
411
- logger: {
412
- level: _types.LOGGER.INFO
413
- }
414
- });
415
- case 4:
416
- callingClient = _context14.sent;
417
- expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
418
- file: _constants.CALLING_CLIENT_FILE,
419
- method: 'getMobiusServers'
420
- });
421
- expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
422
- uri: "".concat(_callingClientFixtures.uri, "myip"),
423
- method: 'GET'
424
- }));
425
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.uri]);
426
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({
427
- method: 'GET'
428
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
429
- uri: "".concat(_callingClientFixtures.uri, "myip")
430
- }));
431
- expect(warnSpy).toBeCalledWith('Error in finding Mobius Servers. Will use the default URL.', '');
432
- case 10:
433
- case "end":
434
- return _context14.stop();
435
- }
436
- }, _callee14);
437
- })));
438
- it('when region discovery succeeds but region based mobius url discovery fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
439
- var failurePayload;
440
- return _regenerator.default.wrap(function _callee15$(_context15) {
441
- while (1) switch (_context15.prev = _context15.next) {
442
- case 0:
443
- failurePayload = {
444
- statusCode: 500
445
- };
446
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockRejectedValueOnce(failurePayload);
447
- _context15.next = 4;
448
- return (0, _CallingClient.createClient)(webex, {
449
- logger: {
450
- level: _types.LOGGER.INFO
451
- }
452
- });
453
- case 4:
454
- callingClient = _context15.sent;
455
- expect(handleErrorSpy).toBeCalledWith(failurePayload, expect.anything(), {
456
- file: _constants.CALLING_CLIENT_FILE,
457
- method: 'getMobiusServers'
458
- });
459
- expect(webex.request).toBeCalledTimes(3);
460
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.uri]);
461
- expect(webex.request).nthCalledWith(1, _objectSpread(_objectSpread({
462
- method: 'GET'
463
- }, (0, _testUtil.getMockRequestTemplate)()), {}, {
464
- uri: "".concat(_callingClientFixtures.uri, "myip")
465
- }));
466
- expect(webex.request).nthCalledWith(2, {
467
- method: 'GET',
468
- uri: "".concat(_constants.DISCOVERY_URL, "/").concat(_callingClientFixtures.myIP),
469
- addAuthHeader: false,
470
- headers: (0, _defineProperty2.default)({}, _constants.SPARK_USER_AGENT, null)
471
- });
472
- expect(warnSpy).toBeCalledWith('Error in finding Mobius Servers. Will use the default URL.', '');
473
- case 11:
474
- case "end":
475
- return _context15.stop();
476
- }
477
- }, _callee15);
478
- })));
479
- it('Verify successful mobius server url discovery after initializing callingClient through a config', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
480
- var infoSpy;
481
- return _regenerator.default.wrap(function _callee16$(_context16) {
482
- while (1) switch (_context16.prev = _context16.next) {
483
- case 0:
484
- infoSpy = jest.spyOn(_Logger.default, 'info');
485
- webex.request.mockResolvedValueOnce(_callingClientFixtures.discoveryPayload);
486
- _context16.next = 4;
487
- return (0, _CallingClient.createClient)(webex, {
488
- discovery: {
489
- region: 'AP-SOUTHEAST',
490
- country: 'IN'
491
- },
492
- logger: {
493
- level: _types.LOGGER.INFO
494
- }
495
- });
496
- case 4:
497
- callingClient = _context16.sent;
498
- expect(callingClient.primaryMobiusUris).toEqual([_callingClientFixtures.primaryUrl]);
499
- expect(infoSpy).toBeCalledWith('Updating region and country from the SDK config', {
500
- file: 'CallingClient',
501
- method: 'getMobiusServers'
502
- });
503
- expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
504
- uri: "".concat(_callingClientFixtures.uri, "?regionCode=").concat(_callingClientFixtures.regionBody.clientRegion, "&countryCode=").concat(_callingClientFixtures.regionBody.countryCode),
505
- method: 'GET'
506
- }));
507
- expect(handleErrorSpy).not.toBeCalled();
508
- case 9:
509
- case "end":
510
- return _context16.stop();
511
- }
512
- }, _callee16);
513
- })));
514
- });
515
- describe('Network activity detection tests', function () {
516
- var callingClient;
517
- var line;
518
- var reg;
519
- var deRegSpy;
520
- var restoreSpy;
521
- var restartRegisterSpy;
522
- var registerSpy;
523
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
524
- return _regenerator.default.wrap(function _callee17$(_context17) {
525
- while (1) switch (_context17.prev = _context17.next) {
526
- case 0:
527
- jest.useFakeTimers();
528
- webex.request.mockResolvedValueOnce(_callingClientFixtures.ipPayload).mockResolvedValueOnce(_callingClientFixtures.regionPayload).mockResolvedValueOnce(_callingClientFixtures.discoveryPayload).mockResolvedValueOnce(_callingClientFixtures.registrationPayload);
529
- _context17.next = 4;
530
- return (0, _CallingClient.createClient)(webex, {
531
- logger: {
532
- level: _types.LOGGER.INFO
533
- }
534
- });
535
- case 4:
536
- callingClient = _context17.sent;
537
- line = (0, _values.default)(callingClient.lineDict)[0];
538
- reg = line.registration;
539
- expect(line.getRegistrationStatus()).toEqual(_types2.MobiusStatus.DEFAULT);
540
- _context17.next = 10;
541
- return line.register();
542
- case 10:
543
- deRegSpy = jest.spyOn(line.registration, 'deregister');
544
- restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
545
- restartRegisterSpy = jest.spyOn(reg, 'restartRegistration');
546
- registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
547
- case 14:
548
- case "end":
549
- return _context17.stop();
550
- }
551
- }, _callee17);
552
- })));
553
- afterEach(function () {
554
- jest.clearAllTimers();
555
- jest.clearAllMocks();
556
- callingClient.removeAllListeners();
557
- callManager.removeAllListeners();
558
- callingClient = undefined;
559
- jest.useRealTimers();
560
- });
561
- it('detect a network flap in mercury connection', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
562
- return _regenerator.default.wrap(function _callee18$(_context18) {
563
- while (1) switch (_context18.prev = _context18.next) {
564
- case 0:
565
- expect(line.getRegistrationStatus()).toEqual(_types2.MobiusStatus.ACTIVE);
566
-
567
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
568
- webex.internal.mercury.connected = false;
569
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
570
-
571
- /* We should be detecting the network flap */
572
- expect(warnSpy).toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
573
- file: _constants.CALLING_CLIENT_FILE,
574
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
575
- });
576
-
577
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
578
- webex.internal.mercury.connected = true;
579
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
580
- _context18.next = 8;
581
- return flushPromises();
582
- case 8:
583
- /* We should be detecting the network recovery */
584
- expect(logSpy).nthCalledWith(7, 'Mercury connection is up again, Re-registering with Mobius', {
585
- file: _constants.REGISTRATION_FILE,
586
- method: 'handleConnectionRestoration'
587
- });
588
- expect(deRegSpy).toBeCalledWith();
589
- expect(restoreSpy).toBeCalledWith('handleConnectionRestoration');
590
- expect(restartRegisterSpy).toBeCalledWith('handleConnectionRestoration');
591
- expect(webex.request).toBeCalledTimes(6);
592
- expect(registerSpy).toBeCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
593
- expect(registerSpy).lastCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
594
- case 15:
595
- case "end":
596
- return _context18.stop();
597
- }
598
- }, _callee18);
599
- })));
600
- it('Simulate a network flap with no active calls and re-verify registration: Restore Failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
601
- var failurePayload, mockRegistrationBody, successPayload;
602
- return _regenerator.default.wrap(function _callee19$(_context19) {
603
- while (1) switch (_context19.prev = _context19.next) {
604
- case 0:
605
- expect(line.getRegistrationStatus()).toEqual(_types2.MobiusStatus.ACTIVE);
606
- failurePayload = {
607
- statusCode: 500,
608
- body: ''
609
- };
610
- mockRegistrationBody = (0, _testUtil.getMockDeviceInfo)();
611
- successPayload = {
612
- statusCode: 200,
613
- body: mockRegistrationBody
614
- };
615
- webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
616
-
617
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
618
- webex.internal.mercury.connected = false;
619
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
620
-
621
- /* We should be detecting the network flap */
622
- expect(warnSpy).toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
623
- file: _constants.CALLING_CLIENT_FILE,
624
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
625
- });
626
-
627
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
628
- webex.internal.mercury.connected = true;
629
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
630
- _context19.next = 12;
631
- return flushPromises();
632
- case 12:
633
- /* We should be detecting the network recovery */
634
- expect(logSpy).toBeCalledWith('Mercury connection is up again, Re-registering with Mobius', {
635
- file: _constants.REGISTRATION_FILE,
636
- method: 'handleConnectionRestoration'
637
- });
638
- expect(deRegSpy).toBeCalledWith();
639
- expect(restoreSpy).toBeCalledWith('handleConnectionRestoration');
640
- expect(restartRegisterSpy).toBeCalledWith('handleConnectionRestoration');
641
- expect(webex.request).toBeCalledTimes(6);
642
- expect(registerSpy).toBeCalledWith('handleConnectionRestoration', [reg.getActiveMobiusUrl()]);
643
- expect(registerSpy).lastCalledWith('handleConnectionRestoration', [_callingClientFixtures.primaryUrl]);
644
- case 19:
645
- case "end":
646
- return _context19.stop();
647
- }
648
- }, _callee19);
649
- })));
650
- it('Simulate a network flap before initial registration is done', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
651
- return _regenerator.default.wrap(function _callee20$(_context20) {
652
- while (1) switch (_context20.prev = _context20.next) {
653
- case 0:
654
- expect(line.getRegistrationStatus()).toEqual(_types2.MobiusStatus.ACTIVE);
655
- reg.deregister();
656
- reg.setActiveMobiusUrl(undefined);
657
- jest.clearAllMocks();
658
-
659
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
660
- webex.internal.mercury.connected = false;
661
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
662
-
663
- /* We should be detecting the network flap */
664
- expect(warnSpy).toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
665
- file: _constants.CALLING_CLIENT_FILE,
666
- method: _constants.NETWORK_CHANGE_DETECTION_UTIL
667
- });
668
-
669
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
670
- webex.internal.mercury.connected = true;
671
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
672
- _context20.next = 11;
673
- return flushPromises();
674
- case 11:
675
- /* We should be detecting the network recovery */
676
- expect(logSpy).toBeCalledWith('Mercury connection is up again, Re-registering with Mobius', {
677
- file: _constants.REGISTRATION_FILE,
678
- method: 'handleConnectionRestoration'
679
- });
680
-
681
- /*
682
- * When initial registration is not done, network flap
683
- * will not trigger de-registration/registration
684
- */
685
- expect(webex.request).not.toBeCalled();
686
- expect(restoreSpy).not.toBeCalled();
687
- expect(registerSpy).not.toBeCalled();
688
- case 15:
689
- case "end":
690
- return _context20.stop();
691
- }
692
- }, _callee20);
693
- })));
694
- it('Simulate a network flap with 1 active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
695
- return _regenerator.default.wrap(function _callee21$(_context21) {
696
- while (1) switch (_context21.prev = _context21.next) {
697
- case 0:
698
- expect(line.getRegistrationStatus()).toEqual(_types2.MobiusStatus.ACTIVE);
699
-
700
- /** create a new call */
701
- reg.callManager.createCall();
702
- expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
703
-
704
- /* Set mercury connection to be down and execute a delay of 2.5 seconds */
705
- webex.internal.mercury.connected = false;
706
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
707
- _context21.next = 7;
708
- return flushPromises();
709
- case 7:
710
- /* We should be detecting the network flap */
711
- expect(warnSpy).not.toBeCalledWith('Network has flapped, waiting for mercury connection to be up', {
712
- file: _constants.CALLING_CLIENT_FILE,
713
- method: 'handleConnectionRestoration'
714
- });
715
-
716
- /* Set mercury connection to be up and execute a delay of 2.5 seconds */
717
- webex.internal.mercury.connected = true;
718
- jest.advanceTimersByTime(_constants.NETWORK_FLAP_TIMEOUT + 500);
719
- _context21.next = 12;
720
- return flushPromises();
721
- case 12:
722
- /* We should be detecting the network recovery */
723
- expect(logSpy).not.toBeCalledWith('Mercury connection is up again, Re-registering with Mobius', {
724
- file: _constants.REGISTRATION_FILE,
725
- method: 'handleConnectionRestoration'
726
- });
727
- expect(registerSpy).not.toBeCalledWith(true);
728
- case 14:
729
- case "end":
730
- return _context21.stop();
731
- }
732
- }, _callee21);
733
- })));
734
- });
735
- describe('Line creation tests', function () {
736
- var callingClient;
737
- var line;
738
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
739
- return _regenerator.default.wrap(function _callee22$(_context22) {
740
- while (1) switch (_context22.prev = _context22.next) {
741
- case 0:
742
- _context22.next = 2;
743
- return (0, _CallingClient.createClient)(webex);
744
- case 2:
745
- callingClient = _context22.sent;
746
- line = (0, _values.default)(callingClient.lineDict)[0];
747
- case 4:
748
- case "end":
749
- return _context22.stop();
750
- }
751
- }, _callee22);
752
- })));
753
- afterEach(function () {
754
- jest.clearAllTimers();
755
- jest.clearAllMocks();
756
- callingClient.removeAllListeners();
757
- callManager.removeAllListeners();
758
- callingClient = undefined;
759
- jest.useRealTimers();
760
- });
761
- it('verify line dict successfully created', function () {
762
- expect(callingClient.lineDict).toBeTruthy();
763
- expect(line).toBeTruthy();
764
- expect((0, _keys.default)(callingClient.lineDict).length).toEqual(1);
765
- });
766
- it('verify getLines response', function () {
767
- expect(callingClient.getLines).toBeTruthy();
768
- expect(callingClient.getLines()).toEqual(callingClient.lineDict);
769
- });
770
- });
771
-
772
- // Calling related test cases
773
- describe('Calling tests', function () {
774
- var mutex = new _asyncMutex.Mutex();
775
- var userId = webex.internal.device.userId;
776
- var clientDeviceUri = webex.internal.device.url;
777
- var mobiusUris = (0, utils.filterMobiusUris)((0, _testUtil.getMobiusDiscoveryResponse)(), _registerFixtures.URL);
778
- var primaryMobiusUris = jest.fn(function () {
779
- return mobiusUris.primary;
780
- });
781
- var backupMobiusUris = jest.fn(function () {
782
- return mobiusUris.backup;
783
- });
784
- var callingClient;
785
- var line;
786
- beforeAll( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
787
- var calls;
788
- return _regenerator.default.wrap(function _callee23$(_context23) {
789
- while (1) switch (_context23.prev = _context23.next) {
790
- case 0:
791
- _context23.next = 2;
792
- return (0, _CallingClient.createClient)(webex);
793
- case 2:
794
- callingClient = _context23.sent;
795
- line = new _line.default(userId, clientDeviceUri, _types4.LineStatus.ACTIVE, mutex, primaryMobiusUris(), backupMobiusUris(), _types.LOGGER.INFO);
796
- calls = (0, _values.default)(callManager.getActiveCalls());
797
- calls.forEach(function (call) {
798
- call.end();
799
- });
800
- case 6:
801
- case "end":
802
- return _context23.stop();
803
- }
804
- }, _callee23);
805
- })));
806
- afterAll(function () {
807
- callingClient.removeAllListeners();
808
- callManager.removeAllListeners();
809
- });
810
- it('verify calling client object', function () {
811
- expect(callingClient.getSDKConnector().getWebex().internal.device.userId).toBe('8a67806f-fc4d-446b-a131-31e71ea5b0e9');
812
- });
813
- it('returns undefined when there is no connected call', function () {
814
- line.register();
815
- line.makeCall({
816
- address: '123456',
817
- type: _types2.CallType.URI
818
- });
819
- expect(callingClient.getConnectedCall()).toEqual(undefined);
820
- });
821
- it('returns the connected call', function () {
822
- line.register();
823
- var mockCall = line.makeCall({
824
- address: '1234',
825
- type: _types2.CallType.URI
826
- });
827
- var mockCall2 = line.makeCall({
828
- address: '5678',
829
- type: _types2.CallType.URI
830
- });
831
- // Connected call
832
- mockCall['connected'] = true;
833
- mockCall['earlyMedia'] = false;
834
- mockCall['callStateMachine'].state.value = 'S_CALL_ESTABLISHED';
835
-
836
- // Held call
837
- mockCall2['connected'] = true;
838
- mockCall2['held'] = true;
839
- mockCall2['earlyMedia'] = false;
840
- mockCall2['callStateMachine'].state.value = 'S_CALL_HOLD';
841
- var mockActiveCalls = {
842
- mockCorrelationId: mockCall,
843
- mockCorrelationId2: mockCall2
844
- };
845
- jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
846
- expect(callingClient.getConnectedCall()).toEqual(mockCall);
847
- });
848
- it('returns all active calls', function () {
849
- callingClient.lineDict = {
850
- mockDeviceId: {
851
- lineId: 'mockLineId'
852
- },
853
- mockDeviceId2: {
854
- lineId: 'mockLineId2'
855
- }
856
- };
857
- var mockCall = line.makeCall({
858
- address: '1234',
859
- type: _types2.CallType.URI
860
- });
861
- var mockCall2 = line.makeCall({
862
- address: '5678',
863
- type: _types2.CallType.URI
864
- });
865
- var mockCall3 = line.makeCall({
866
- address: '9101',
867
- type: _types2.CallType.URI
868
- });
869
- mockCall.lineId = 'mockLineId';
870
- mockCall2.lineId = 'mockLineId2';
871
- mockCall3.lineId = 'mockLineId2';
872
- var mockActiveCalls = {
873
- mockCorrelationId: mockCall,
874
- mockCorrelationId2: mockCall2,
875
- mockCorrelationId3: mockCall3
876
- };
877
- jest.spyOn(callManager, 'getActiveCalls').mockReturnValue(mockActiveCalls);
878
- expect(callingClient.getActiveCalls()).toEqual({
879
- mockLineId: [mockCall],
880
- mockLineId2: [mockCall2, mockCall3]
881
- });
882
- });
883
- });
884
- describe('Call Session Event test', function () {
885
- var mockOn = webex.internal.mercury.on;
886
- var callingClient;
887
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
888
- return _regenerator.default.wrap(function _callee24$(_context24) {
889
- while (1) switch (_context24.prev = _context24.next) {
890
- case 0:
891
- _context24.next = 2;
892
- return (0, _CallingClient.createClient)(webex, {
893
- logger: {
894
- level: _types.LOGGER.INFO
895
- }
896
- });
897
- case 2:
898
- callingClient = _context24.sent;
899
- case 3:
900
- case "end":
901
- return _context24.stop();
902
- }
903
- }, _callee24);
904
- })));
905
- afterEach(function () {
906
- callingClient.removeAllListeners();
907
- callManager.removeAllListeners();
908
- });
909
- it('verify the recent user session event ', function (done) {
910
- expect.assertions(2);
911
- callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
912
- expect(event.data).toEqual(_callRecordFixtures.MOCK_SESSION_EVENT.data);
913
- done();
914
- });
915
- expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
916
- var callSessionCallback = mockOn.mock.calls[0][1];
917
- callSessionCallback(_callRecordFixtures.MOCK_SESSION_EVENT);
918
- });
919
- it('drop the recent user session if there is no webex calling type', function (done) {
920
- expect.assertions(2);
921
- callingClient.on(_types3.CALLING_CLIENT_EVENT_KEYS.USER_SESSION_INFO, function (event) {
922
- expect(event.data.userSessions.userSessions.length).toEqual(1);
923
- done();
924
- });
925
- expect(mockOn.mock.calls[0][0]).toEqual(_types3.MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE);
926
- var callSessionCallback = mockOn.mock.calls[0][1];
927
- callSessionCallback(_callRecordFixtures.MOCK_MULTIPLE_SESSIONS_EVENT);
928
- });
929
- });
930
- });
931
- //# sourceMappingURL=CallingClient.test.js.map