@webex/webex-core 3.0.0-beta.2 → 3.0.0-beta.21

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 (184) hide show
  1. package/dist/config.js +1 -11
  2. package/dist/config.js.map +1 -1
  3. package/dist/credentials-config.js +44 -64
  4. package/dist/credentials-config.js.map +1 -1
  5. package/dist/index.js +0 -76
  6. package/dist/index.js.map +1 -1
  7. package/dist/interceptors/auth.js +22 -55
  8. package/dist/interceptors/auth.js.map +1 -1
  9. package/dist/interceptors/default-options.js +0 -20
  10. package/dist/interceptors/default-options.js.map +1 -1
  11. package/dist/interceptors/embargo.js +0 -21
  12. package/dist/interceptors/embargo.js.map +1 -1
  13. package/dist/interceptors/network-timing.js +2 -21
  14. package/dist/interceptors/network-timing.js.map +1 -1
  15. package/dist/interceptors/payload-transformer.js +2 -22
  16. package/dist/interceptors/payload-transformer.js.map +1 -1
  17. package/dist/interceptors/rate-limit.js +25 -57
  18. package/dist/interceptors/rate-limit.js.map +1 -1
  19. package/dist/interceptors/redirect.js +4 -33
  20. package/dist/interceptors/redirect.js.map +1 -1
  21. package/dist/interceptors/request-event.js +3 -30
  22. package/dist/interceptors/request-event.js.map +1 -1
  23. package/dist/interceptors/request-logger.js +1 -30
  24. package/dist/interceptors/request-logger.js.map +1 -1
  25. package/dist/interceptors/request-timing.js +3 -22
  26. package/dist/interceptors/request-timing.js.map +1 -1
  27. package/dist/interceptors/response-logger.js +2 -31
  28. package/dist/interceptors/response-logger.js.map +1 -1
  29. package/dist/interceptors/user-agent.js +2 -29
  30. package/dist/interceptors/user-agent.js.map +1 -1
  31. package/dist/interceptors/webex-tracking-id.js +5 -28
  32. package/dist/interceptors/webex-tracking-id.js.map +1 -1
  33. package/dist/interceptors/webex-user-agent.js +5 -38
  34. package/dist/interceptors/webex-user-agent.js.map +1 -1
  35. package/dist/lib/batcher.js +3 -51
  36. package/dist/lib/batcher.js.map +1 -1
  37. package/dist/lib/credentials/credentials.js +39 -119
  38. package/dist/lib/credentials/credentials.js.map +1 -1
  39. package/dist/lib/credentials/grant-errors.js +0 -49
  40. package/dist/lib/credentials/grant-errors.js.map +1 -1
  41. package/dist/lib/credentials/index.js +1 -13
  42. package/dist/lib/credentials/index.js.map +1 -1
  43. package/dist/lib/credentials/scope.js +1 -7
  44. package/dist/lib/credentials/scope.js.map +1 -1
  45. package/dist/lib/credentials/token-collection.js +1 -7
  46. package/dist/lib/credentials/token-collection.js.map +1 -1
  47. package/dist/lib/credentials/token.js +39 -118
  48. package/dist/lib/credentials/token.js.map +1 -1
  49. package/dist/lib/page.js +13 -26
  50. package/dist/lib/page.js.map +1 -1
  51. package/dist/lib/services/constants.js +0 -2
  52. package/dist/lib/services/constants.js.map +1 -1
  53. package/dist/lib/services/index.js +1 -28
  54. package/dist/lib/services/index.js.map +1 -1
  55. package/dist/lib/services/interceptors/server-error.js +2 -23
  56. package/dist/lib/services/interceptors/server-error.js.map +1 -1
  57. package/dist/lib/services/interceptors/service.js +12 -34
  58. package/dist/lib/services/interceptors/service.js.map +1 -1
  59. package/dist/lib/services/metrics.js +0 -2
  60. package/dist/lib/services/metrics.js.map +1 -1
  61. package/dist/lib/services/service-catalog.js +10 -90
  62. package/dist/lib/services/service-catalog.js.map +1 -1
  63. package/dist/lib/services/service-fed-ramp.js +0 -2
  64. package/dist/lib/services/service-fed-ramp.js.map +1 -1
  65. package/dist/lib/services/service-host.js +47 -62
  66. package/dist/lib/services/service-host.js.map +1 -1
  67. package/dist/lib/services/service-registry.js +78 -90
  68. package/dist/lib/services/service-registry.js.map +1 -1
  69. package/dist/lib/services/service-state.js +3 -15
  70. package/dist/lib/services/service-state.js.map +1 -1
  71. package/dist/lib/services/service-url.js +4 -25
  72. package/dist/lib/services/service-url.js.map +1 -1
  73. package/dist/lib/services/services.js +122 -238
  74. package/dist/lib/services/services.js.map +1 -1
  75. package/dist/lib/stateless-webex-plugin.js +5 -28
  76. package/dist/lib/stateless-webex-plugin.js.map +1 -1
  77. package/dist/lib/storage/decorators.js +19 -62
  78. package/dist/lib/storage/decorators.js.map +1 -1
  79. package/dist/lib/storage/errors.js +0 -23
  80. package/dist/lib/storage/errors.js.map +1 -1
  81. package/dist/lib/storage/index.js +2 -16
  82. package/dist/lib/storage/index.js.map +1 -1
  83. package/dist/lib/storage/make-webex-plugin-store.js +11 -41
  84. package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
  85. package/dist/lib/storage/make-webex-store.js +8 -30
  86. package/dist/lib/storage/make-webex-store.js.map +1 -1
  87. package/dist/lib/storage/memory-store-adapter.js +1 -19
  88. package/dist/lib/storage/memory-store-adapter.js.map +1 -1
  89. package/dist/lib/webex-core-plugin-mixin.js +9 -29
  90. package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
  91. package/dist/lib/webex-http-error.js +1 -31
  92. package/dist/lib/webex-http-error.js.map +1 -1
  93. package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
  94. package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
  95. package/dist/lib/webex-plugin.js +6 -40
  96. package/dist/lib/webex-plugin.js.map +1 -1
  97. package/dist/plugins/logger.js +3 -17
  98. package/dist/plugins/logger.js.map +1 -1
  99. package/dist/webex-core.js +79 -203
  100. package/dist/webex-core.js.map +1 -1
  101. package/dist/webex-internal-core.js +0 -10
  102. package/dist/webex-internal-core.js.map +1 -1
  103. package/package.json +14 -14
  104. package/src/config.js +9 -11
  105. package/src/credentials-config.js +110 -72
  106. package/src/index.js +4 -14
  107. package/src/interceptors/auth.js +36 -37
  108. package/src/interceptors/default-options.js +0 -1
  109. package/src/interceptors/embargo.js +1 -1
  110. package/src/interceptors/payload-transformer.js +1 -2
  111. package/src/interceptors/rate-limit.js +8 -5
  112. package/src/interceptors/redirect.js +14 -8
  113. package/src/interceptors/request-event.js +4 -8
  114. package/src/interceptors/request-logger.js +8 -5
  115. package/src/interceptors/response-logger.js +11 -8
  116. package/src/interceptors/user-agent.js +1 -2
  117. package/src/interceptors/webex-user-agent.js +3 -9
  118. package/src/lib/batcher.js +70 -69
  119. package/src/lib/credentials/credentials.js +112 -122
  120. package/src/lib/credentials/grant-errors.js +6 -7
  121. package/src/lib/credentials/index.js +1 -4
  122. package/src/lib/credentials/scope.js +1 -4
  123. package/src/lib/credentials/token-collection.js +1 -1
  124. package/src/lib/credentials/token.js +86 -80
  125. package/src/lib/page.js +10 -11
  126. package/src/lib/services/constants.js +3 -13
  127. package/src/lib/services/index.js +2 -2
  128. package/src/lib/services/interceptors/server-error.js +12 -7
  129. package/src/lib/services/interceptors/service.js +6 -5
  130. package/src/lib/services/metrics.js +1 -1
  131. package/src/lib/services/service-catalog.js +110 -100
  132. package/src/lib/services/service-fed-ramp.js +1 -2
  133. package/src/lib/services/service-host.js +10 -17
  134. package/src/lib/services/service-registry.js +69 -96
  135. package/src/lib/services/service-state.js +4 -6
  136. package/src/lib/services/service-url.js +24 -23
  137. package/src/lib/services/services.js +260 -251
  138. package/src/lib/stateless-webex-plugin.js +4 -2
  139. package/src/lib/storage/decorators.js +68 -66
  140. package/src/lib/storage/index.js +4 -6
  141. package/src/lib/storage/make-webex-plugin-store.js +34 -21
  142. package/src/lib/storage/make-webex-store.js +6 -7
  143. package/src/lib/storage/memory-store-adapter.js +3 -3
  144. package/src/lib/webex-core-plugin-mixin.js +10 -7
  145. package/src/lib/webex-http-error.js +7 -8
  146. package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
  147. package/src/lib/webex-plugin.js +41 -34
  148. package/src/plugins/logger.js +8 -3
  149. package/src/webex-core.js +185 -116
  150. package/src/webex-internal-core.js +15 -9
  151. package/test/integration/spec/credentials/credentials.js +26 -30
  152. package/test/integration/spec/credentials/token.js +36 -33
  153. package/test/integration/spec/services/service-catalog.js +177 -156
  154. package/test/integration/spec/services/services.js +313 -304
  155. package/test/integration/spec/webex-core.js +98 -86
  156. package/test/unit/spec/_setup.js +26 -18
  157. package/test/unit/spec/credentials/credentials.js +189 -154
  158. package/test/unit/spec/credentials/token.js +94 -76
  159. package/test/unit/spec/interceptors/auth.js +291 -243
  160. package/test/unit/spec/interceptors/default-options.js +36 -24
  161. package/test/unit/spec/interceptors/embargo.js +32 -27
  162. package/test/unit/spec/interceptors/network-timing.js +2 -2
  163. package/test/unit/spec/interceptors/payload-transformer.js +61 -52
  164. package/test/unit/spec/interceptors/rate-limit.js +104 -75
  165. package/test/unit/spec/interceptors/redirect.js +22 -20
  166. package/test/unit/spec/interceptors/request-timing.js +18 -22
  167. package/test/unit/spec/interceptors/user-agent.js +28 -16
  168. package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
  169. package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
  170. package/test/unit/spec/lib/batcher.js +36 -32
  171. package/test/unit/spec/lib/page.js +36 -32
  172. package/test/unit/spec/lib/webex-plugin.js +1 -1
  173. package/test/unit/spec/services/interceptors/server-error.js +67 -90
  174. package/test/unit/spec/services/interceptors/service.js +17 -28
  175. package/test/unit/spec/services/service-catalog.js +19 -27
  176. package/test/unit/spec/services/service-host.js +29 -26
  177. package/test/unit/spec/services/service-registry.js +128 -170
  178. package/test/unit/spec/services/service-state.js +13 -22
  179. package/test/unit/spec/services/service-url.js +24 -43
  180. package/test/unit/spec/services/services.js +85 -41
  181. package/test/unit/spec/storage/persist.js +6 -9
  182. package/test/unit/spec/storage/wait-for-value.js +22 -21
  183. package/test/unit/spec/webex-core.js +78 -57
  184. package/test/unit/spec/webex-internal-core.js +56 -31
@@ -14,54 +14,53 @@ describe('webex-core', () => {
14
14
  fixture = {
15
15
  serviceLinks: {
16
16
  'example-service-a-name': 'http://example-service-a.com/',
17
- 'example-service-b-name': 'http://example-service-b.com/'
17
+ 'example-service-b-name': 'http://example-service-b.com/',
18
18
  },
19
19
  hostCatalog: {
20
20
  'example-service-a': [
21
21
  {
22
22
  host: 'example-service-a-h1.com',
23
23
  id: 'head:group:cluster-a-h1:example-service-a-name',
24
- priority: 5
24
+ priority: 5,
25
25
  },
26
26
  {
27
27
  host: 'example-service-a-h2.com',
28
28
  id: 'head:group:cluster-a-h2:example-service-a-name',
29
- priority: 3
30
- }
29
+ priority: 3,
30
+ },
31
31
  ],
32
32
  'example-service-b': [
33
33
  {
34
34
  host: 'example-service-b-h1.com',
35
35
  id: 'head:group:cluster-b-h1:example-service-b-name',
36
- priority: 5
36
+ priority: 5,
37
37
  },
38
38
  {
39
39
  host: 'example-service-b-h2.com',
40
40
  id: 'head:group:cluster-b-h2:example-service-b-name',
41
- priority: 3
42
- }
41
+ priority: 3,
42
+ },
43
43
  ],
44
44
  'example-service-c': [
45
45
  {
46
46
  host: 'example-service-c-h1.com',
47
47
  id: 'head:group:cluster-c-h1:example-service-a-name',
48
- priority: 5
48
+ priority: 5,
49
49
  },
50
50
  {
51
51
  host: 'example-service-c-h2.com',
52
52
  id: 'head:group:cluster-c-h2:example-service-a-name',
53
- priority: 3
54
- }
55
- ]
56
- }
53
+ priority: 3,
54
+ },
55
+ ],
56
+ },
57
57
  };
58
58
 
59
- fixtureHosts = Object.keys(fixture.hostCatalog)
60
- .reduce((output, key) => {
61
- output.push(...fixture.hostCatalog[key]);
59
+ fixtureHosts = Object.keys(fixture.hostCatalog).reduce((output, key) => {
60
+ output.push(...fixture.hostCatalog[key]);
62
61
 
63
- return output;
64
- }, []);
62
+ return output;
63
+ }, []);
65
64
  });
66
65
 
67
66
  beforeEach('initialize a service catalog', () => {
@@ -82,7 +81,7 @@ describe('webex-core', () => {
82
81
  serviceRegistry.load(
83
82
  ServiceRegistry.mapRemoteCatalog({
84
83
  catalog: SERVICE_CATALOGS[0],
85
- ...fixture
84
+ ...fixture,
86
85
  })
87
86
  );
88
87
 
@@ -90,7 +89,7 @@ describe('webex-core', () => {
90
89
 
91
90
  priorityLocalHosts = {
92
91
  'example-service-a-name': hostCatalog['example-service-a'][0].host,
93
- 'example-service-b-name': hostCatalog['example-service-b'][0].host
92
+ 'example-service-b-name': hostCatalog['example-service-b'][0].host,
94
93
  };
95
94
  });
96
95
 
@@ -98,9 +97,9 @@ describe('webex-core', () => {
98
97
  const {map} = serviceRegistry;
99
98
  const priorityLocalHostsKeys = Object.keys(priorityLocalHosts);
100
99
 
101
- assert.isTrue(priorityLocalHostsKeys.every(
102
- (key) => map[key].includes(priorityLocalHosts[key])
103
- ));
100
+ assert.isTrue(
101
+ priorityLocalHostsKeys.every((key) => map[key].includes(priorityLocalHosts[key]))
102
+ );
104
103
  });
105
104
  });
106
105
  });
@@ -110,10 +109,12 @@ describe('webex-core', () => {
110
109
  let host;
111
110
 
112
111
  beforeEach('generate the service host class objects', () => {
113
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
114
- catalog: SERVICE_CATALOGS[0],
115
- ...fixture
116
- }));
112
+ serviceRegistry.load(
113
+ ServiceRegistry.mapRemoteCatalog({
114
+ catalog: SERVICE_CATALOGS[0],
115
+ ...fixture,
116
+ })
117
+ );
117
118
 
118
119
  host = serviceRegistry.hosts[0];
119
120
 
@@ -124,7 +125,7 @@ describe('webex-core', () => {
124
125
  local: true,
125
126
  priority: true,
126
127
  service: host.service,
127
- url: host.url
128
+ url: host.url,
128
129
  };
129
130
  });
130
131
 
@@ -158,10 +159,12 @@ describe('webex-core', () => {
158
159
  let filteredHost;
159
160
 
160
161
  beforeEach('generate the service host class objects', () => {
161
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
162
- catalog: SERVICE_CATALOGS[0],
163
- ...fixture
164
- }));
162
+ serviceRegistry.load(
163
+ ServiceRegistry.mapRemoteCatalog({
164
+ catalog: SERVICE_CATALOGS[0],
165
+ ...fixture,
166
+ })
167
+ );
165
168
 
166
169
  filteredHost = serviceRegistry.hosts[0];
167
170
 
@@ -172,15 +175,13 @@ describe('webex-core', () => {
172
175
  local: true,
173
176
  priority: true,
174
177
  service: filteredHost.service,
175
- url: filteredHost.url
178
+ url: filteredHost.url,
176
179
  };
177
180
  });
178
181
 
179
182
  it('should mark all hosts as failed when called without a filter', () => {
180
183
  serviceRegistry.failed();
181
- assert.isTrue(serviceRegistry.hosts.every(
182
- (failedHost) => failedHost.failed
183
- ));
184
+ assert.isTrue(serviceRegistry.hosts.every((failedHost) => failedHost.failed));
184
185
  });
185
186
 
186
187
  it('should mark the target hosts as failed', () => {
@@ -203,7 +204,7 @@ describe('webex-core', () => {
203
204
  beforeEach('generate the service host class objects', () => {
204
205
  hostList = ServiceRegistry.mapRemoteCatalog({
205
206
  catalog: SERVICE_CATALOGS[0],
206
- ...fixture
207
+ ...fixture,
207
208
  });
208
209
 
209
210
  serviceRegistry.load(hostList);
@@ -240,12 +241,12 @@ describe('webex-core', () => {
240
241
  beforeEach('generate the service host class objects', () => {
241
242
  hostsCustomA = ServiceRegistry.mapRemoteCatalog({
242
243
  catalog: SERVICE_CATALOGS[0],
243
- ...fixture
244
+ ...fixture,
244
245
  });
245
246
 
246
247
  hostsCustomB = ServiceRegistry.mapRemoteCatalog({
247
248
  catalog: SERVICE_CATALOGS[1],
248
- ...fixture
249
+ ...fixture,
249
250
  });
250
251
 
251
252
  serviceRegistry.load(hostsCustomA);
@@ -262,37 +263,26 @@ describe('webex-core', () => {
262
263
  filteredHosts = serviceRegistry.filterCatalog(SERVICE_CATALOGS[0]);
263
264
 
264
265
  assert.equal(filteredHosts.length, hostsCustomA.length);
265
- assert.isTrue(filteredHosts.every(
266
- (host) => host.catalog === SERVICE_CATALOGS[0]
267
- ));
266
+ assert.isTrue(filteredHosts.every((host) => host.catalog === SERVICE_CATALOGS[0]));
268
267
  });
269
268
 
270
269
  it('should return service hosts for an array of catalogs', () => {
271
- filteredHosts = serviceRegistry.filterCatalog(
272
- [SERVICE_CATALOGS[0], SERVICE_CATALOGS[1]]
273
- );
270
+ filteredHosts = serviceRegistry.filterCatalog([SERVICE_CATALOGS[0], SERVICE_CATALOGS[1]]);
274
271
 
275
- assert.equal(
276
- filteredHosts.length,
277
- (hostsCustomA.length + hostsCustomB.length)
278
- );
272
+ assert.equal(filteredHosts.length, hostsCustomA.length + hostsCustomB.length);
279
273
 
280
- assert.isTrue(filteredHosts.every(
281
- (host) => [SERVICE_CATALOGS[0], SERVICE_CATALOGS[1]].includes(
282
- host.catalog
274
+ assert.isTrue(
275
+ filteredHosts.every((host) =>
276
+ [SERVICE_CATALOGS[0], SERVICE_CATALOGS[1]].includes(host.catalog)
283
277
  )
284
- ));
278
+ );
285
279
  });
286
280
 
287
281
  it('should return only service hosts from valid catalogs', () => {
288
- filteredHosts = serviceRegistry.filterCatalog(
289
- [SERVICE_CATALOGS[0], 'invalid', -1]
290
- );
282
+ filteredHosts = serviceRegistry.filterCatalog([SERVICE_CATALOGS[0], 'invalid', -1]);
291
283
 
292
284
  assert.equal(filteredHosts.length, hostsCustomA.length);
293
- assert.isTrue(filteredHosts.every(
294
- (host) => host.catalog === SERVICE_CATALOGS[0]
295
- ));
285
+ assert.isTrue(filteredHosts.every((host) => host.catalog === SERVICE_CATALOGS[0]));
296
286
  });
297
287
  });
298
288
 
@@ -305,14 +295,14 @@ describe('webex-core', () => {
305
295
  serviceRegistry.load(
306
296
  ServiceRegistry.mapRemoteCatalog({
307
297
  catalog: SERVICE_CATALOGS[0],
308
- ...fixture
298
+ ...fixture,
309
299
  })
310
300
  );
311
301
 
312
302
  remoteHosts = fixture.hostCatalog['example-service-c'];
313
303
  localHosts = [
314
304
  ...fixture.hostCatalog['example-service-a'],
315
- ...fixture.hostCatalog['example-service-b']
305
+ ...fixture.hostCatalog['example-service-b'],
316
306
  ];
317
307
  });
318
308
 
@@ -326,18 +316,14 @@ describe('webex-core', () => {
326
316
  filteredHosts = serviceRegistry.filterLocal(true);
327
317
 
328
318
  assert.equal(filteredHosts.length, localHosts.length);
329
- assert.isTrue(filteredHosts.every(
330
- (host) => host.local === true
331
- ));
319
+ assert.isTrue(filteredHosts.every((host) => host.local === true));
332
320
  });
333
321
 
334
322
  it('should return only hosts remote hosts when called with false', () => {
335
323
  filteredHosts = serviceRegistry.filterLocal(false);
336
324
 
337
325
  assert.equal(filteredHosts.length, remoteHosts.length);
338
- assert.isTrue(filteredHosts.every(
339
- (host) => host.local === false
340
- ));
326
+ assert.isTrue(filteredHosts.every((host) => host.local === false));
341
327
  });
342
328
  });
343
329
 
@@ -349,14 +335,14 @@ describe('webex-core', () => {
349
335
  serviceRegistry.load(
350
336
  ServiceRegistry.mapRemoteCatalog({
351
337
  catalog: SERVICE_CATALOGS[0],
352
- ...fixture
338
+ ...fixture,
353
339
  })
354
340
  );
355
341
 
356
342
  priorityHosts = [
357
343
  fixture.hostCatalog['example-service-a'][0],
358
344
  fixture.hostCatalog['example-service-b'][0],
359
- fixture.hostCatalog['example-service-c'][0]
345
+ fixture.hostCatalog['example-service-c'][0],
360
346
  ];
361
347
  });
362
348
 
@@ -401,17 +387,15 @@ describe('webex-core', () => {
401
387
  serviceRegistry.load(
402
388
  ServiceRegistry.mapRemoteCatalog({
403
389
  catalog: SERVICE_CATALOGS[0],
404
- ...fixture
390
+ ...fixture,
405
391
  })
406
392
  );
407
393
 
408
- otherHosts = [
409
- ...fixture.hostCatalog['example-service-b']
410
- ];
394
+ otherHosts = [...fixture.hostCatalog['example-service-b']];
411
395
 
412
396
  serviceHosts = [
413
397
  ...fixture.hostCatalog['example-service-a'],
414
- ...fixture.hostCatalog['example-service-c']
398
+ ...fixture.hostCatalog['example-service-c'],
415
399
  ];
416
400
 
417
401
  otherServiceName = 'example-service-b-name';
@@ -428,25 +412,17 @@ describe('webex-core', () => {
428
412
  filteredHosts = serviceRegistry.filterService(serviceName);
429
413
 
430
414
  assert.equal(filteredHosts.length, serviceHosts.length);
431
- assert.isTrue(filteredHosts.every(
432
- (host) => host.service === serviceName
433
- ));
415
+ assert.isTrue(filteredHosts.every((host) => host.service === serviceName));
434
416
  });
435
417
 
436
418
  it('should return all hosts that belong to an array of services', () => {
437
- filteredHosts = serviceRegistry.filterService([
438
- otherServiceName,
439
- serviceName
440
- ]);
441
-
442
- assert.equal(
443
- filteredHosts.length,
444
- [...otherHosts, ...serviceHosts].length
445
- );
419
+ filteredHosts = serviceRegistry.filterService([otherServiceName, serviceName]);
446
420
 
447
- assert.isTrue(filteredHosts.every(
448
- (host) => [otherServiceName, serviceName].includes(host.service)
449
- ));
421
+ assert.equal(filteredHosts.length, [...otherHosts, ...serviceHosts].length);
422
+
423
+ assert.isTrue(
424
+ filteredHosts.every((host) => [otherServiceName, serviceName].includes(host.service))
425
+ );
450
426
  });
451
427
 
452
428
  it('should return an empty array when given an invalid service', () => {
@@ -465,7 +441,7 @@ describe('webex-core', () => {
465
441
  serviceRegistry.load(
466
442
  ServiceRegistry.mapRemoteCatalog({
467
443
  catalog: SERVICE_CATALOGS[0],
468
- ...fixture
444
+ ...fixture,
469
445
  })
470
446
  );
471
447
 
@@ -486,15 +462,12 @@ describe('webex-core', () => {
486
462
  });
487
463
 
488
464
  it('should return service hosts for an array of urls', () => {
489
- filteredHosts = serviceRegistry.filterUrl([
490
- filteredHostA.url,
491
- filteredHostB.url
492
- ]);
465
+ filteredHosts = serviceRegistry.filterUrl([filteredHostA.url, filteredHostB.url]);
493
466
 
494
467
  assert.equal(filteredHosts.length, 2);
495
- assert.isTrue(filteredHosts.every(
496
- (foundHost) => [filteredHostA, filteredHostB].includes(foundHost)
497
- ));
468
+ assert.isTrue(
469
+ filteredHosts.every((foundHost) => [filteredHostA, filteredHostB].includes(foundHost))
470
+ );
498
471
  });
499
472
 
500
473
  it('should return an empty array when given an invalid url', () => {
@@ -508,10 +481,12 @@ describe('webex-core', () => {
508
481
  let host;
509
482
 
510
483
  beforeEach('generate the service host class objects', () => {
511
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
512
- catalog: SERVICE_CATALOGS[0],
513
- ...fixture
514
- }));
484
+ serviceRegistry.load(
485
+ ServiceRegistry.mapRemoteCatalog({
486
+ catalog: SERVICE_CATALOGS[0],
487
+ ...fixture,
488
+ })
489
+ );
515
490
 
516
491
  host = serviceRegistry.hosts[0];
517
492
 
@@ -522,47 +497,47 @@ describe('webex-core', () => {
522
497
  local: true,
523
498
  priority: true,
524
499
  service: host.service,
525
- url: host.url
500
+ url: host.url,
526
501
  };
527
502
  });
528
503
 
529
- it('should call the \'filterActive()\' method with params', () => {
504
+ it("should call the 'filterActive()' method with params", () => {
530
505
  sinon.spy(serviceRegistry, 'filterActive');
531
506
  serviceRegistry.find(filter);
532
507
  assert.calledWith(serviceRegistry.filterActive, filter.active);
533
508
  });
534
509
 
535
- it('should call the \'filterCatalog()\' method with params', () => {
510
+ it("should call the 'filterCatalog()' method with params", () => {
536
511
  sinon.spy(serviceRegistry, 'filterCatalog');
537
512
  serviceRegistry.find(filter);
538
513
  assert.calledWith(serviceRegistry.filterCatalog, filter.catalog);
539
514
  });
540
515
 
541
- it('should call the \'filterCluster()\' method with params', () => {
516
+ it("should call the 'filterCluster()' method with params", () => {
542
517
  sinon.spy(serviceRegistry, 'filterCluster');
543
518
  serviceRegistry.find(filter);
544
519
  assert.calledWith(serviceRegistry.filterCluster, filter.cluster);
545
520
  });
546
521
 
547
- it('should call the \'filterLocal()\' method with params', () => {
522
+ it("should call the 'filterLocal()' method with params", () => {
548
523
  sinon.spy(serviceRegistry, 'filterLocal');
549
524
  serviceRegistry.find(filter);
550
525
  assert.calledWith(serviceRegistry.filterLocal, filter.local);
551
526
  });
552
527
 
553
- it('should call the \'filterPriority()\' method with params', () => {
528
+ it("should call the 'filterPriority()' method with params", () => {
554
529
  sinon.spy(serviceRegistry, 'filterPriority');
555
530
  serviceRegistry.find(filter);
556
531
  assert.calledWith(serviceRegistry.filterPriority, filter.priority);
557
532
  });
558
533
 
559
- it('should call the \'filterService()\' method with params', () => {
534
+ it("should call the 'filterService()' method with params", () => {
560
535
  sinon.spy(serviceRegistry, 'filterService');
561
536
  serviceRegistry.find(filter);
562
537
  assert.calledWith(serviceRegistry.filterService, filter.service);
563
538
  });
564
539
 
565
- it('should call the \'filterUrl()\' method with params', () => {
540
+ it("should call the 'filterUrl()' method with params", () => {
566
541
  sinon.spy(serviceRegistry, 'filterUrl');
567
542
  serviceRegistry.find(filter);
568
543
  assert.calledWith(serviceRegistry.filterUrl, filter.url);
@@ -584,10 +559,12 @@ describe('webex-core', () => {
584
559
 
585
560
  describe('#load()', () => {
586
561
  it('should amend all provided hosts to the hosts array', () => {
587
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
588
- catalog: SERVICE_CATALOGS[0],
589
- ...fixture
590
- }));
562
+ serviceRegistry.load(
563
+ ServiceRegistry.mapRemoteCatalog({
564
+ catalog: SERVICE_CATALOGS[0],
565
+ ...fixture,
566
+ })
567
+ );
591
568
 
592
569
  assert.equal(serviceRegistry.hosts.length, fixtureHosts.length);
593
570
  });
@@ -595,7 +572,7 @@ describe('webex-core', () => {
595
572
  it('should ignore unloadable hosts', () => {
596
573
  const unloadables = ServiceRegistry.mapRemoteCatalog({
597
574
  catalog: SERVICE_CATALOGS[0],
598
- ...fixture
575
+ ...fixture,
599
576
  }).map((unloadable) => ({...unloadable, catalog: 'invalid'}));
600
577
 
601
578
  serviceRegistry.load(unloadables);
@@ -613,10 +590,12 @@ describe('webex-core', () => {
613
590
  let filteredHost;
614
591
 
615
592
  beforeEach('generate the service host class objects', () => {
616
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
617
- catalog: SERVICE_CATALOGS[0],
618
- ...fixture
619
- }));
593
+ serviceRegistry.load(
594
+ ServiceRegistry.mapRemoteCatalog({
595
+ catalog: SERVICE_CATALOGS[0],
596
+ ...fixture,
597
+ })
598
+ );
620
599
 
621
600
  filteredHost = serviceRegistry.hosts[0];
622
601
 
@@ -627,15 +606,13 @@ describe('webex-core', () => {
627
606
  local: true,
628
607
  priority: true,
629
608
  service: filteredHost.service,
630
- url: filteredHost.url
609
+ url: filteredHost.url,
631
610
  };
632
611
  });
633
612
 
634
613
  it('should mark all hosts as replaced when called without params', () => {
635
614
  serviceRegistry.replaced();
636
- assert.isTrue(serviceRegistry.hosts.every(
637
- (replacedHost) => replacedHost.replaced
638
- ));
615
+ assert.isTrue(serviceRegistry.hosts.every((replacedHost) => replacedHost.replaced));
639
616
  });
640
617
 
641
618
  it('should mark the target hosts as replaced', () => {
@@ -655,15 +632,17 @@ describe('webex-core', () => {
655
632
  let filteredHost;
656
633
 
657
634
  beforeEach('generate the service host class objects', () => {
658
- serviceRegistry.load(ServiceRegistry.mapRemoteCatalog({
659
- catalog: SERVICE_CATALOGS[0],
660
- ...fixture
661
- }));
635
+ serviceRegistry.load(
636
+ ServiceRegistry.mapRemoteCatalog({
637
+ catalog: SERVICE_CATALOGS[0],
638
+ ...fixture,
639
+ })
640
+ );
662
641
 
663
642
  filteredHost = serviceRegistry.hosts[0];
664
643
 
665
644
  filter = {
666
- url: filteredHost.url
645
+ url: filteredHost.url,
667
646
  };
668
647
 
669
648
  serviceRegistry.failed();
@@ -671,9 +650,7 @@ describe('webex-core', () => {
671
650
 
672
651
  it('should reset all hosts when called withour a filter', () => {
673
652
  serviceRegistry.reset();
674
- assert.isTrue(serviceRegistry.hosts.every(
675
- (resetHost) => resetHost.failed === false
676
- ));
653
+ assert.isTrue(serviceRegistry.hosts.every((resetHost) => resetHost.failed === false));
677
654
  });
678
655
 
679
656
  it('should reset the failed status of the target host', () => {
@@ -683,17 +660,15 @@ describe('webex-core', () => {
683
660
 
684
661
  it('should not reset the failed status of non-targetted hosts', () => {
685
662
  serviceRegistry.reset(filter);
686
- assert.isTrue(serviceRegistry.hosts.every(
687
- (foundHost) => foundHost.failed || foundHost === filteredHost
688
- ));
663
+ assert.isTrue(
664
+ serviceRegistry.hosts.every((foundHost) => foundHost.failed || foundHost === filteredHost)
665
+ );
689
666
  });
690
667
 
691
668
  it('should not reset the replaced status of hosts', () => {
692
669
  serviceRegistry.replaced();
693
670
  serviceRegistry.reset();
694
- assert.isTrue(serviceRegistry.hosts.every(
695
- (foundHost) => foundHost.replaced
696
- ));
671
+ assert.isTrue(serviceRegistry.hosts.every((foundHost) => foundHost.replaced));
697
672
  });
698
673
 
699
674
  it('should return the reset host', () => {
@@ -714,43 +689,27 @@ describe('webex-core', () => {
714
689
  });
715
690
 
716
691
  it('should map an index to the matching name', () => {
717
- assert.equal(
718
- ServiceRegistry.mapCatalogName({id: index, type: SCET.STRING}),
719
- name
720
- );
692
+ assert.equal(ServiceRegistry.mapCatalogName({id: index, type: SCET.STRING}), name);
721
693
  });
722
694
 
723
695
  it('should map an index to the matching index', () => {
724
- assert.equal(
725
- ServiceRegistry.mapCatalogName({id: index, type: SCET.NUMBER}),
726
- index
727
- );
696
+ assert.equal(ServiceRegistry.mapCatalogName({id: index, type: SCET.NUMBER}), index);
728
697
  });
729
698
 
730
699
  it('should map a name to the matching index', () => {
731
- assert.equal(
732
- ServiceRegistry.mapCatalogName({id: name, type: SCET.NUMBER}),
733
- index
734
- );
700
+ assert.equal(ServiceRegistry.mapCatalogName({id: name, type: SCET.NUMBER}), index);
735
701
  });
736
702
 
737
703
  it('should map a name to the matching name', () => {
738
- assert.equal(
739
- ServiceRegistry.mapCatalogName({id: name, type: SCET.STRING}),
740
- name
741
- );
704
+ assert.equal(ServiceRegistry.mapCatalogName({id: name, type: SCET.STRING}), name);
742
705
  });
743
706
 
744
- it('should return undefined if an index doesn\'t exist', () => {
745
- assert.isUndefined(
746
- ServiceRegistry.mapCatalogName({id: -1, type: SCET.NUMBER})
747
- );
707
+ it("should return undefined if an index doesn't exist", () => {
708
+ assert.isUndefined(ServiceRegistry.mapCatalogName({id: -1, type: SCET.NUMBER}));
748
709
  });
749
710
 
750
- it('should return undefined if a name doesn\'t exist', () => {
751
- assert.isUndefined(
752
- ServiceRegistry.mapCatalogName({id: 'invalid', type: SCET.NUMBER})
753
- );
711
+ it("should return undefined if a name doesn't exist", () => {
712
+ assert.isUndefined(ServiceRegistry.mapCatalogName({id: 'invalid', type: SCET.NUMBER}));
754
713
  });
755
714
  });
756
715
 
@@ -758,7 +717,7 @@ describe('webex-core', () => {
758
717
  it('should return an array', () => {
759
718
  const mappedHosts = ServiceRegistry.mapRemoteCatalog({
760
719
  catalog: SERVICE_CATALOGS[0],
761
- ...fixture
720
+ ...fixture,
762
721
  });
763
722
 
764
723
  assert.isArray(mappedHosts);
@@ -767,17 +726,19 @@ describe('webex-core', () => {
767
726
  it('should include all provided hosts', () => {
768
727
  const mappedHosts = ServiceRegistry.mapRemoteCatalog({
769
728
  catalog: SERVICE_CATALOGS[0],
770
- ...fixture
729
+ ...fixture,
771
730
  });
772
731
 
773
732
  assert.equal(mappedHosts.length, fixtureHosts.length);
774
733
  });
775
734
 
776
735
  it('should not map using an invalid catalog name', () => {
777
- assert.throws(() => ServiceRegistry.mapRemoteCatalog({
778
- catalog: 'invalid',
779
- ...fixture
780
- }));
736
+ assert.throws(() =>
737
+ ServiceRegistry.mapRemoteCatalog({
738
+ catalog: 'invalid',
739
+ ...fixture,
740
+ })
741
+ );
781
742
  });
782
743
 
783
744
  it('should map catalog indexes to catalog names', () => {
@@ -785,13 +746,10 @@ describe('webex-core', () => {
785
746
 
786
747
  const mappedHosts = ServiceRegistry.mapRemoteCatalog({
787
748
  catalog: catalogIndex,
788
- ...fixture
749
+ ...fixture,
789
750
  });
790
751
 
791
- assert.equal(
792
- mappedHosts[0].catalog,
793
- SERVICE_CATALOGS[catalogIndex]
794
- );
752
+ assert.equal(mappedHosts[0].catalog, SERVICE_CATALOGS[catalogIndex]);
795
753
  });
796
754
  });
797
755
  });