@webex/internal-plugin-device 3.0.0-beta.4 → 3.0.0-beta.400
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.
- package/README.md +10 -6
- package/dist/config.js +9 -9
- package/dist/config.js.map +1 -1
- package/dist/constants.js +2 -3
- package/dist/constants.js.map +1 -1
- package/dist/device.js +114 -172
- package/dist/device.js.map +1 -1
- package/dist/features/feature-collection.js +1 -8
- package/dist/features/feature-collection.js.map +1 -1
- package/dist/features/feature-model.js +15 -42
- package/dist/features/feature-model.js.map +1 -1
- package/dist/features/features-model.js +9 -21
- package/dist/features/features-model.js.map +1 -1
- package/dist/features/index.js +0 -8
- package/dist/features/index.js.map +1 -1
- package/dist/index.js +2 -24
- package/dist/index.js.map +1 -1
- package/dist/interceptors/device-url.js +12 -33
- package/dist/interceptors/device-url.js.map +1 -1
- package/dist/ipNetworkDetector.js +200 -0
- package/dist/ipNetworkDetector.js.map +1 -0
- package/dist/metrics.js +0 -2
- package/dist/metrics.js.map +1 -1
- package/package.json +10 -10
- package/src/config.js +17 -9
- package/src/constants.js +3 -5
- package/src/device.js +164 -146
- package/src/features/feature-collection.js +1 -1
- package/src/features/feature-model.js +5 -11
- package/src/features/features-model.js +3 -9
- package/src/features/index.js +1 -5
- package/src/index.js +3 -11
- package/src/interceptors/device-url.js +5 -7
- package/src/ipNetworkDetector.ts +176 -0
- package/src/metrics.js +1 -2
- package/test/integration/spec/device.js +210 -239
- package/test/integration/spec/webex.js +9 -9
- package/test/unit/spec/device.js +110 -53
- package/test/unit/spec/features/feature-collection.js +2 -2
- package/test/unit/spec/features/feature-model.js +23 -39
- package/test/unit/spec/features/features-model.js +4 -12
- package/test/unit/spec/interceptors/device-url.js +69 -109
- package/test/unit/spec/ipNetworkDetector.js +410 -0
- package/test/unit/spec/wdm-dto.json +5 -13
|
@@ -11,14 +11,15 @@ describe('plugin-device', () => {
|
|
|
11
11
|
let user;
|
|
12
12
|
let webex;
|
|
13
13
|
|
|
14
|
-
before('create users', () =>
|
|
15
|
-
.then(([createdUser]) => {
|
|
14
|
+
before('create users', () =>
|
|
15
|
+
testUsers.create({count: 1}).then(([createdUser]) => {
|
|
16
16
|
user = createdUser;
|
|
17
|
-
})
|
|
17
|
+
})
|
|
18
|
+
);
|
|
18
19
|
|
|
19
20
|
beforeEach('create webex instance', () => {
|
|
20
21
|
webex = new WebexCore({
|
|
21
|
-
credentials: user.token
|
|
22
|
+
credentials: user.token,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
device = webex.internal.device;
|
|
@@ -32,11 +33,10 @@ describe('plugin-device', () => {
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
it('unregisters the device', () =>
|
|
35
|
-
webex.logout({noRedirect: true})
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}));
|
|
36
|
+
webex.logout({noRedirect: true}).then(() => {
|
|
37
|
+
assert.called(device.unregister);
|
|
38
|
+
assert.isFalse(device.registered);
|
|
39
|
+
}));
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
});
|
package/test/unit/spec/device.js
CHANGED
|
@@ -15,8 +15,8 @@ describe('plugin-device', () => {
|
|
|
15
15
|
beforeEach('initialize webex with the device plugin', () => {
|
|
16
16
|
webex = new MockWebex({
|
|
17
17
|
children: {
|
|
18
|
-
device: Device
|
|
19
|
-
}
|
|
18
|
+
device: Device,
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const clonedDTO = cloneDeep(dto);
|
|
@@ -35,20 +35,17 @@ describe('plugin-device', () => {
|
|
|
35
35
|
spy = sinon.spy();
|
|
36
36
|
modifiedDTOFeatures = {
|
|
37
37
|
...dto.features,
|
|
38
|
-
user: [
|
|
39
|
-
...dto.features.user,
|
|
40
|
-
...dto.features.developer
|
|
41
|
-
]
|
|
38
|
+
user: [...dto.features.user, ...dto.features.developer],
|
|
42
39
|
};
|
|
43
40
|
});
|
|
44
41
|
|
|
45
|
-
it(
|
|
42
|
+
it("should trigger a 'change' event", () => {
|
|
46
43
|
device.on('change', spy);
|
|
47
44
|
device.features.set(modifiedDTOFeatures);
|
|
48
45
|
assert.called(spy);
|
|
49
46
|
});
|
|
50
47
|
|
|
51
|
-
it(
|
|
48
|
+
it("should trigger a 'change:features' event", () => {
|
|
52
49
|
device.on('change:features', spy);
|
|
53
50
|
device.features.set(modifiedDTOFeatures);
|
|
54
51
|
assert.called(spy);
|
|
@@ -60,12 +57,12 @@ describe('plugin-device', () => {
|
|
|
60
57
|
device.checkNetworkReachability = sinon.spy();
|
|
61
58
|
});
|
|
62
59
|
|
|
63
|
-
describe(
|
|
64
|
-
beforeEach(
|
|
60
|
+
describe("when the 'intranetInactivityCheckUrl' changes", () => {
|
|
61
|
+
beforeEach("change 'intranetInactivityCheckUrl'", () => {
|
|
65
62
|
device.intranetInactivityCheckUrl = 'https://not-a-url.com';
|
|
66
63
|
});
|
|
67
64
|
|
|
68
|
-
it(
|
|
65
|
+
it("should call 'checkNetworkReachability()'", () => {
|
|
69
66
|
assert.called(device.checkNetworkReachability);
|
|
70
67
|
});
|
|
71
68
|
|
|
@@ -74,12 +71,12 @@ describe('plugin-device', () => {
|
|
|
74
71
|
});
|
|
75
72
|
});
|
|
76
73
|
|
|
77
|
-
describe(
|
|
78
|
-
beforeEach(
|
|
74
|
+
describe("when the 'intranetInactivityDuration' changes", () => {
|
|
75
|
+
beforeEach("change 'intranetInactivityDuration'", () => {
|
|
79
76
|
device.intranetInactivityDuration = 1234;
|
|
80
77
|
});
|
|
81
78
|
|
|
82
|
-
it(
|
|
79
|
+
it("should call 'checkNetworkReachability()'", () => {
|
|
83
80
|
assert.called(device.checkNetworkReachability);
|
|
84
81
|
});
|
|
85
82
|
|
|
@@ -88,12 +85,12 @@ describe('plugin-device', () => {
|
|
|
88
85
|
});
|
|
89
86
|
});
|
|
90
87
|
|
|
91
|
-
describe(
|
|
92
|
-
beforeEach(
|
|
88
|
+
describe("when the 'inNetworkInactivityDuration' changes", () => {
|
|
89
|
+
beforeEach("change 'inNetworkInactivityDuration'", () => {
|
|
93
90
|
device.inNetworkInactivityDuration = 1234;
|
|
94
91
|
});
|
|
95
92
|
|
|
96
|
-
it(
|
|
93
|
+
it("should call 'checkNetworkReachability()'", () => {
|
|
97
94
|
assert.called(device.checkNetworkReachability);
|
|
98
95
|
assert.isTrue(device.isReachabilityChecked);
|
|
99
96
|
});
|
|
@@ -104,7 +101,7 @@ describe('plugin-device', () => {
|
|
|
104
101
|
describe('derived properties', () => {
|
|
105
102
|
describe('#registered', () => {
|
|
106
103
|
describe('when the device does not have a url', () => {
|
|
107
|
-
beforeEach(
|
|
104
|
+
beforeEach("remove the device's url", () => {
|
|
108
105
|
device.url = undefined;
|
|
109
106
|
});
|
|
110
107
|
|
|
@@ -114,7 +111,7 @@ describe('plugin-device', () => {
|
|
|
114
111
|
});
|
|
115
112
|
|
|
116
113
|
describe('when the device does have a url', () => {
|
|
117
|
-
beforeEach(
|
|
114
|
+
beforeEach("set the device's url", () => {
|
|
118
115
|
device.url = dto.url;
|
|
119
116
|
});
|
|
120
117
|
|
|
@@ -149,7 +146,7 @@ describe('plugin-device', () => {
|
|
|
149
146
|
device.resetLogoutTimer = sinon.spy();
|
|
150
147
|
});
|
|
151
148
|
|
|
152
|
-
it(
|
|
149
|
+
it("should create a 'change:lastUserActivityDate' listener", () => {
|
|
153
150
|
device.setLogoutTimer(60000);
|
|
154
151
|
device.trigger('change:lastUserActivityDate');
|
|
155
152
|
assert.called(device.resetLogoutTimer);
|
|
@@ -173,10 +170,7 @@ describe('plugin-device', () => {
|
|
|
173
170
|
});
|
|
174
171
|
|
|
175
172
|
it('should serialize user feature keys', () => {
|
|
176
|
-
assert.hasAllKeys(
|
|
177
|
-
device.serialize().features.user,
|
|
178
|
-
Object.keys(dto.features.user)
|
|
179
|
-
);
|
|
173
|
+
assert.hasAllKeys(device.serialize().features.user, Object.keys(dto.features.user));
|
|
180
174
|
});
|
|
181
175
|
});
|
|
182
176
|
|
|
@@ -201,7 +195,7 @@ describe('plugin-device', () => {
|
|
|
201
195
|
await result;
|
|
202
196
|
|
|
203
197
|
assert.deepEqual(requestSpy.args[0][0].headers, {
|
|
204
|
-
'If-None-Match': 'etag-value'
|
|
198
|
+
'If-None-Match': 'etag-value',
|
|
205
199
|
});
|
|
206
200
|
});
|
|
207
201
|
|
|
@@ -216,6 +210,72 @@ describe('plugin-device', () => {
|
|
|
216
210
|
});
|
|
217
211
|
});
|
|
218
212
|
|
|
213
|
+
describe('#register()', () => {
|
|
214
|
+
const setup = () => {
|
|
215
|
+
webex.internal.metrics.submitClientMetrics = sinon.stub();
|
|
216
|
+
|
|
217
|
+
sinon.stub(device, 'processRegistrationSuccess').callsFake(() => {});
|
|
218
|
+
|
|
219
|
+
device.config.defaults = {};
|
|
220
|
+
device.set('registered', false);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
it('checks that submitInternalEvent gets called with internal.register.device.request', async () => {
|
|
224
|
+
setup();
|
|
225
|
+
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
|
|
226
|
+
sinon.spy(device, 'request');
|
|
227
|
+
|
|
228
|
+
await device.register();
|
|
229
|
+
|
|
230
|
+
assert.calledWith(webex.internal.newMetrics.submitInternalEvent, {
|
|
231
|
+
name: 'internal.register.device.request',
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('checks that submitInternalEvent gets called with internal.register.device.response on error', async () => {
|
|
237
|
+
setup();
|
|
238
|
+
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
|
|
239
|
+
sinon.stub(device, 'request').rejects(new Error('some error'));
|
|
240
|
+
|
|
241
|
+
const result = device.register();
|
|
242
|
+
|
|
243
|
+
await assert.isRejected(result);
|
|
244
|
+
|
|
245
|
+
assert.calledWith(webex.internal.newMetrics.submitInternalEvent, {
|
|
246
|
+
name: 'internal.register.device.response',
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('checks that submitInternalEvent gets called with internal.register.device.response on success', async () => {
|
|
252
|
+
setup();
|
|
253
|
+
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
|
|
254
|
+
|
|
255
|
+
sinon.stub(device, 'request').callsFake(() => Promise.resolve({
|
|
256
|
+
exampleKey: 'example response value',
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
await device.register();
|
|
260
|
+
|
|
261
|
+
assert.calledWith(webex.internal.newMetrics.submitInternalEvent, {
|
|
262
|
+
name: 'internal.register.device.response',
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('checks that submitInternalEvent not called when canRegister fails', async () => {
|
|
267
|
+
setup();
|
|
268
|
+
sinon.stub(device, 'canRegister').rejects(new Error('some error'));
|
|
269
|
+
|
|
270
|
+
const result = device.register();
|
|
271
|
+
|
|
272
|
+
await assert.isRejected(result);
|
|
273
|
+
|
|
274
|
+
assert.notCalled(webex.internal.newMetrics.submitInternalEvent);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
});
|
|
278
|
+
|
|
219
279
|
describe('#processRegistrationSuccess()', () => {
|
|
220
280
|
const getClonedDTO = (overrides) => {
|
|
221
281
|
const clonedDTO = cloneDeep(dto);
|
|
@@ -228,7 +288,7 @@ describe('plugin-device', () => {
|
|
|
228
288
|
val: 'true',
|
|
229
289
|
value: true,
|
|
230
290
|
mutable: true,
|
|
231
|
-
lastModified: '2015-06-29T20:02:48.033Z'
|
|
291
|
+
lastModified: '2015-06-29T20:02:48.033Z',
|
|
232
292
|
},
|
|
233
293
|
],
|
|
234
294
|
entitlement: [
|
|
@@ -236,18 +296,18 @@ describe('plugin-device', () => {
|
|
|
236
296
|
key: '2',
|
|
237
297
|
val: 'true',
|
|
238
298
|
value: true,
|
|
239
|
-
mutable: false
|
|
240
|
-
}
|
|
299
|
+
mutable: false,
|
|
300
|
+
},
|
|
241
301
|
],
|
|
242
302
|
user: [
|
|
243
303
|
{
|
|
244
304
|
key: '3',
|
|
245
305
|
val: 'true',
|
|
246
306
|
value: true,
|
|
247
|
-
mutable: true
|
|
248
|
-
}
|
|
307
|
+
mutable: true,
|
|
308
|
+
},
|
|
249
309
|
],
|
|
250
|
-
...overrides
|
|
310
|
+
...overrides,
|
|
251
311
|
};
|
|
252
312
|
|
|
253
313
|
return clonedDTO;
|
|
@@ -267,11 +327,9 @@ describe('plugin-device', () => {
|
|
|
267
327
|
|
|
268
328
|
const response = {
|
|
269
329
|
body: {
|
|
270
|
-
...clonedDTO
|
|
330
|
+
...clonedDTO,
|
|
271
331
|
},
|
|
272
|
-
headers: {
|
|
273
|
-
|
|
274
|
-
}
|
|
332
|
+
headers: {},
|
|
275
333
|
};
|
|
276
334
|
|
|
277
335
|
checkFeatureNotPresent('developer', '1');
|
|
@@ -292,11 +350,11 @@ describe('plugin-device', () => {
|
|
|
292
350
|
|
|
293
351
|
const response = {
|
|
294
352
|
body: {
|
|
295
|
-
...clonedDTO
|
|
353
|
+
...clonedDTO,
|
|
296
354
|
},
|
|
297
355
|
headers: {
|
|
298
|
-
etag: 'etag-value'
|
|
299
|
-
}
|
|
356
|
+
etag: 'etag-value',
|
|
357
|
+
},
|
|
300
358
|
};
|
|
301
359
|
|
|
302
360
|
checkFeatureNotPresent('developer', '1');
|
|
@@ -320,11 +378,11 @@ describe('plugin-device', () => {
|
|
|
320
378
|
|
|
321
379
|
const response = {
|
|
322
380
|
body: {
|
|
323
|
-
...clonedDTO
|
|
381
|
+
...clonedDTO,
|
|
324
382
|
},
|
|
325
383
|
headers: {
|
|
326
|
-
etag: 'etag-value'
|
|
327
|
-
}
|
|
384
|
+
etag: 'etag-value',
|
|
385
|
+
},
|
|
328
386
|
};
|
|
329
387
|
|
|
330
388
|
checkFeatureNotPresent('developer', '1');
|
|
@@ -348,11 +406,11 @@ describe('plugin-device', () => {
|
|
|
348
406
|
|
|
349
407
|
const response = {
|
|
350
408
|
body: {
|
|
351
|
-
...clonedDTO
|
|
409
|
+
...clonedDTO,
|
|
352
410
|
},
|
|
353
411
|
headers: {
|
|
354
|
-
etag: 'different-etag-value'
|
|
355
|
-
}
|
|
412
|
+
etag: 'different-etag-value',
|
|
413
|
+
},
|
|
356
414
|
};
|
|
357
415
|
|
|
358
416
|
checkFeatureNotPresent('developer', '1');
|
|
@@ -376,7 +434,7 @@ describe('plugin-device', () => {
|
|
|
376
434
|
val: 'false',
|
|
377
435
|
value: false,
|
|
378
436
|
mutable: true,
|
|
379
|
-
lastModified: '2015-06-29T20:02:48.033Z'
|
|
437
|
+
lastModified: '2015-06-29T20:02:48.033Z',
|
|
380
438
|
},
|
|
381
439
|
],
|
|
382
440
|
entitlement: [
|
|
@@ -384,27 +442,26 @@ describe('plugin-device', () => {
|
|
|
384
442
|
key: '2',
|
|
385
443
|
val: 'false',
|
|
386
444
|
value: false,
|
|
387
|
-
mutable: false
|
|
388
|
-
}
|
|
445
|
+
mutable: false,
|
|
446
|
+
},
|
|
389
447
|
],
|
|
390
448
|
user: [
|
|
391
449
|
{
|
|
392
450
|
key: '3',
|
|
393
451
|
val: 'false',
|
|
394
452
|
value: false,
|
|
395
|
-
mutable: true
|
|
396
|
-
}
|
|
453
|
+
mutable: true,
|
|
454
|
+
},
|
|
397
455
|
],
|
|
398
456
|
});
|
|
399
457
|
|
|
400
|
-
|
|
401
458
|
const newResponse = {
|
|
402
459
|
body: {
|
|
403
|
-
...newClonedDTO
|
|
460
|
+
...newClonedDTO,
|
|
404
461
|
},
|
|
405
462
|
headers: {
|
|
406
|
-
etag: 'different-etag-value'
|
|
407
|
-
}
|
|
463
|
+
etag: 'different-etag-value',
|
|
464
|
+
},
|
|
408
465
|
};
|
|
409
466
|
|
|
410
467
|
device.processRegistrationSuccess(newResponse);
|
|
@@ -10,13 +10,13 @@ describe('plugin-device', () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
describe('#mainIndex', () => {
|
|
13
|
-
it(
|
|
13
|
+
it("should have its index set to 'key'", () => {
|
|
14
14
|
assert.equal(featureCollection.mainIndex, 'key');
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
describe('#model', () => {
|
|
19
|
-
it(
|
|
19
|
+
it("should have its model set to the 'FeatureModel' class", () => {
|
|
20
20
|
assert.equal(featureCollection.model, FeatureModel);
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -14,7 +14,7 @@ describe('plugin-device', () => {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
describe('#constructor()', () => {
|
|
17
|
-
describe(
|
|
17
|
+
describe("when the feature includes a 'lastModified' property", () => {
|
|
18
18
|
beforeEach('generate the feature model', () => {
|
|
19
19
|
featureModel = new FeatureModel(featureLM);
|
|
20
20
|
});
|
|
@@ -27,17 +27,14 @@ describe('plugin-device', () => {
|
|
|
27
27
|
assert.equal(featureLM.value, featureModel.value);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it(
|
|
30
|
+
it("should assign the 'lastModified' value as a 'Date'", () => {
|
|
31
31
|
assert.instanceOf(featureModel.lastModified, Date);
|
|
32
32
|
|
|
33
|
-
assert.equal(
|
|
34
|
-
featureModel.lastModified.toISOString(),
|
|
35
|
-
featureLM.lastModified
|
|
36
|
-
);
|
|
33
|
+
assert.equal(featureModel.lastModified.toISOString(), featureLM.lastModified);
|
|
37
34
|
});
|
|
38
35
|
});
|
|
39
36
|
|
|
40
|
-
describe(
|
|
37
|
+
describe("when the feature excludes a 'lastModified' property", () => {
|
|
41
38
|
beforeEach('generate the feature model', () => {
|
|
42
39
|
featureModel = new FeatureModel(featureNLM);
|
|
43
40
|
});
|
|
@@ -50,7 +47,7 @@ describe('plugin-device', () => {
|
|
|
50
47
|
assert.equal(featureNLM.value, featureModel.value);
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
it(
|
|
50
|
+
it("should not assign the 'lastModified' value", () => {
|
|
54
51
|
assert.isUndefined(featureModel.lastModified);
|
|
55
52
|
});
|
|
56
53
|
});
|
|
@@ -83,8 +80,7 @@ describe('plugin-device', () => {
|
|
|
83
80
|
it('should set the value to a instance of number', () =>
|
|
84
81
|
assert.typeOf(model.value, 'number'));
|
|
85
82
|
|
|
86
|
-
it(
|
|
87
|
-
assert.equal(model.type, 'number'));
|
|
83
|
+
it("should set the type to 'number'", () => assert.equal(model.type, 'number'));
|
|
88
84
|
|
|
89
85
|
it('should set the model value to the equivalent Number value', () =>
|
|
90
86
|
assert.equal(model.value, Number(fixture.val)));
|
|
@@ -96,11 +92,9 @@ describe('plugin-device', () => {
|
|
|
96
92
|
model = featureModel.parse(fixture);
|
|
97
93
|
});
|
|
98
94
|
|
|
99
|
-
it('should set the value to a boolean true', () =>
|
|
100
|
-
assert.equal(model.value, true));
|
|
95
|
+
it('should set the value to a boolean true', () => assert.equal(model.value, true));
|
|
101
96
|
|
|
102
|
-
it(
|
|
103
|
-
assert.equal(model.type, 'boolean'));
|
|
97
|
+
it("should set the type to 'boolean'", () => assert.equal(model.type, 'boolean'));
|
|
104
98
|
});
|
|
105
99
|
|
|
106
100
|
describe('when the value is a True boolean', () => {
|
|
@@ -109,11 +103,9 @@ describe('plugin-device', () => {
|
|
|
109
103
|
model = featureModel.parse(fixture);
|
|
110
104
|
});
|
|
111
105
|
|
|
112
|
-
it('should set the value to a boolean true', () =>
|
|
113
|
-
assert.equal(model.value, true));
|
|
106
|
+
it('should set the value to a boolean true', () => assert.equal(model.value, true));
|
|
114
107
|
|
|
115
|
-
it(
|
|
116
|
-
assert.equal(model.type, 'boolean'));
|
|
108
|
+
it("should set the type to 'boolean'", () => assert.equal(model.type, 'boolean'));
|
|
117
109
|
});
|
|
118
110
|
|
|
119
111
|
describe('when the value is a false string', () => {
|
|
@@ -122,11 +114,9 @@ describe('plugin-device', () => {
|
|
|
122
114
|
model = featureModel.parse(fixture);
|
|
123
115
|
});
|
|
124
116
|
|
|
125
|
-
it('should set the value to a boolean false', () =>
|
|
126
|
-
assert.equal(model.value, false));
|
|
117
|
+
it('should set the value to a boolean false', () => assert.equal(model.value, false));
|
|
127
118
|
|
|
128
|
-
it(
|
|
129
|
-
assert.equal(model.type, 'boolean'));
|
|
119
|
+
it("should set the type to 'boolean'", () => assert.equal(model.type, 'boolean'));
|
|
130
120
|
});
|
|
131
121
|
|
|
132
122
|
describe('when the value is a False string', () => {
|
|
@@ -135,11 +125,9 @@ describe('plugin-device', () => {
|
|
|
135
125
|
model = featureModel.parse(fixture);
|
|
136
126
|
});
|
|
137
127
|
|
|
138
|
-
it('should set the value to a boolean false', () =>
|
|
139
|
-
assert.equal(model.value, false));
|
|
128
|
+
it('should set the value to a boolean false', () => assert.equal(model.value, false));
|
|
140
129
|
|
|
141
|
-
it(
|
|
142
|
-
assert.equal(model.type, 'boolean'));
|
|
130
|
+
it("should set the type to 'boolean'", () => assert.equal(model.type, 'boolean'));
|
|
143
131
|
});
|
|
144
132
|
|
|
145
133
|
describe('when the value is a string', () => {
|
|
@@ -151,8 +139,7 @@ describe('plugin-device', () => {
|
|
|
151
139
|
it('should set the value to a instance of string', () =>
|
|
152
140
|
assert.typeOf(model.value, 'string'));
|
|
153
141
|
|
|
154
|
-
it(
|
|
155
|
-
assert.equal(model.type, 'string'));
|
|
142
|
+
it("should set the type to 'string'", () => assert.equal(model.type, 'string'));
|
|
156
143
|
|
|
157
144
|
it('should set the model value to the equivalent string value', () =>
|
|
158
145
|
assert.equal(model.value, fixture.val));
|
|
@@ -167,8 +154,7 @@ describe('plugin-device', () => {
|
|
|
167
154
|
it('should set the value to the provided val property', () =>
|
|
168
155
|
assert.equal(model.value, fixture.val));
|
|
169
156
|
|
|
170
|
-
it(
|
|
171
|
-
assert.equal(model.type, 'string'));
|
|
157
|
+
it("should set the type to 'string'", () => assert.equal(model.type, 'string'));
|
|
172
158
|
});
|
|
173
159
|
|
|
174
160
|
describe('when there is no value', () => {
|
|
@@ -177,11 +163,9 @@ describe('plugin-device', () => {
|
|
|
177
163
|
model = featureModel.parse(fixture);
|
|
178
164
|
});
|
|
179
165
|
|
|
180
|
-
it('should set the value to undefined', () =>
|
|
181
|
-
assert.isUndefined(model.value));
|
|
166
|
+
it('should set the value to undefined', () => assert.isUndefined(model.value));
|
|
182
167
|
|
|
183
|
-
it(
|
|
184
|
-
assert.equal(model.type, 'string'));
|
|
168
|
+
it("should set the type to 'string'", () => assert.equal(model.type, 'string'));
|
|
185
169
|
});
|
|
186
170
|
});
|
|
187
171
|
});
|
|
@@ -189,7 +173,7 @@ describe('plugin-device', () => {
|
|
|
189
173
|
describe('#serialize()', () => {
|
|
190
174
|
let serialized;
|
|
191
175
|
|
|
192
|
-
describe(
|
|
176
|
+
describe("when the feature includes a 'lastModified' property", () => {
|
|
193
177
|
beforeEach('generate the feature model', () => {
|
|
194
178
|
featureModel = new FeatureModel(featureLM);
|
|
195
179
|
serialized = featureModel.serialize();
|
|
@@ -203,13 +187,13 @@ describe('plugin-device', () => {
|
|
|
203
187
|
assert.equal(featureLM.value, serialized.value);
|
|
204
188
|
});
|
|
205
189
|
|
|
206
|
-
it(
|
|
190
|
+
it("should assign the 'lastModified' value as a 'string'", () => {
|
|
207
191
|
assert.typeOf(serialized.lastModified, 'string');
|
|
208
192
|
assert.equal(serialized.lastModified, featureLM.lastModified);
|
|
209
193
|
});
|
|
210
194
|
});
|
|
211
195
|
|
|
212
|
-
describe(
|
|
196
|
+
describe("when the feature excludes a 'lastModified' property", () => {
|
|
213
197
|
beforeEach('generate the feature model', () => {
|
|
214
198
|
featureModel = new FeatureModel(featureNLM);
|
|
215
199
|
serialized = featureModel.serialize();
|
|
@@ -223,7 +207,7 @@ describe('plugin-device', () => {
|
|
|
223
207
|
assert.equal(featureNLM.value, serialized.value);
|
|
224
208
|
});
|
|
225
209
|
|
|
226
|
-
it(
|
|
210
|
+
it("should not assign the 'lastModified' value", () => {
|
|
227
211
|
assert.isUndefined(serialized.lastModified);
|
|
228
212
|
});
|
|
229
213
|
});
|
|
@@ -234,7 +218,7 @@ describe('plugin-device', () => {
|
|
|
234
218
|
let key;
|
|
235
219
|
let value;
|
|
236
220
|
|
|
237
|
-
beforeEach(
|
|
221
|
+
beforeEach("configure feature and set 'key' and 'value'", () => {
|
|
238
222
|
key = 'val';
|
|
239
223
|
value = 'false';
|
|
240
224
|
featureModel = new FeatureModel(featureLM);
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import {assert} from '@webex/test-helper-chai';
|
|
2
|
-
import {
|
|
3
|
-
constants,
|
|
4
|
-
FeatureModel,
|
|
5
|
-
FeaturesModel
|
|
6
|
-
} from '@webex/internal-plugin-device';
|
|
2
|
+
import {constants, FeatureModel, FeaturesModel} from '@webex/internal-plugin-device';
|
|
7
3
|
import sinon from 'sinon';
|
|
8
4
|
|
|
9
5
|
import dto from '../wdm-dto';
|
|
@@ -17,12 +13,8 @@ describe('plugin-device', () => {
|
|
|
17
13
|
});
|
|
18
14
|
|
|
19
15
|
describe('collections', () => {
|
|
20
|
-
it(
|
|
21
|
-
assert.containsAllKeys(featuresModel, [
|
|
22
|
-
'developer',
|
|
23
|
-
'entitlement',
|
|
24
|
-
'user'
|
|
25
|
-
]);
|
|
16
|
+
it("should have 'developer', 'entitlement' and 'user' keys", () => {
|
|
17
|
+
assert.containsAllKeys(featuresModel, ['developer', 'entitlement', 'user']);
|
|
26
18
|
});
|
|
27
19
|
});
|
|
28
20
|
|
|
@@ -58,7 +50,7 @@ describe('plugin-device', () => {
|
|
|
58
50
|
key = 'testKey';
|
|
59
51
|
model = new FeatureModel({
|
|
60
52
|
...dto.features[collectionName][0],
|
|
61
|
-
key
|
|
53
|
+
key,
|
|
62
54
|
});
|
|
63
55
|
spy = sinon.spy();
|
|
64
56
|
|