@webex/internal-plugin-avatar 3.0.0-beta.14 → 3.0.0-beta.15
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 +1 -3
- package/dist/avatar-url-batcher.js.map +1 -1
- package/dist/avatar-url-store.js.map +1 -1
- package/dist/avatar.js +2 -2
- package/dist/avatar.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/avatar-url-batcher.js +40 -31
- package/src/avatar-url-store.js +1 -1
- package/src/avatar.js +52 -41
- package/src/config.js +2 -2
- package/src/index.js +1 -1
- package/test/integration/spec/avatar.js +15 -14
- package/test/unit/spec/avatar-url-batcher.js +24 -15
- package/test/unit/spec/avatar-url-store.js +110 -58
- package/test/unit/spec/avatar.js +1453 -1217
|
@@ -14,17 +14,21 @@ describe('plugin-avatar', () => {
|
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
webex = new MockWebex({
|
|
16
16
|
children: {
|
|
17
|
-
avatar: Avatar
|
|
18
|
-
}
|
|
17
|
+
avatar: Avatar,
|
|
18
|
+
},
|
|
19
19
|
});
|
|
20
20
|
batcher = webex.internal.avatar.batcher;
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
describe('#fingerprints', () => {
|
|
24
|
-
it(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
it("fingerprintRequest returns 'uuid-size'", () =>
|
|
25
|
+
batcher
|
|
26
|
+
.fingerprintRequest({uuid: 'uuid1', size: 80})
|
|
27
|
+
.then((result) => assert.deepEqual(result, 'uuid1-80')));
|
|
28
|
+
it("fingerprintResponse returns 'uuid-size'", () =>
|
|
29
|
+
batcher
|
|
30
|
+
.fingerprintRequest({uuid: 'uuid1', size: 80})
|
|
31
|
+
.then((result) => assert.deepEqual(result, 'uuid1-80')));
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
describe('#submitHttpRequest()', () => {
|
|
@@ -32,7 +36,7 @@ describe('plugin-avatar', () => {
|
|
|
32
36
|
method: 'POST',
|
|
33
37
|
api: 'avatar',
|
|
34
38
|
resource: 'profiles/urls',
|
|
35
|
-
body: 'foo'
|
|
39
|
+
body: 'foo',
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
it('calls webex.request with expected params', () => {
|
|
@@ -41,7 +45,8 @@ describe('plugin-avatar', () => {
|
|
|
41
45
|
};
|
|
42
46
|
|
|
43
47
|
// webex.requestPromise = Promise.resolve(mockRequest);
|
|
44
|
-
return batcher
|
|
48
|
+
return batcher
|
|
49
|
+
.submitHttpRequest(mockRequest.body)
|
|
45
50
|
.then((req) => assert.deepEqual(req, mockRequest));
|
|
46
51
|
});
|
|
47
52
|
});
|
|
@@ -54,7 +59,7 @@ describe('plugin-avatar', () => {
|
|
|
54
59
|
warn = batcher.logger.warn;
|
|
55
60
|
loggerWarned = false;
|
|
56
61
|
batcher.logger.warn = (msg) => {
|
|
57
|
-
loggerWarned =
|
|
62
|
+
loggerWarned = msg === 'Avatar: substituted size "256" for "80"';
|
|
58
63
|
};
|
|
59
64
|
});
|
|
60
65
|
|
|
@@ -62,14 +67,18 @@ describe('plugin-avatar', () => {
|
|
|
62
67
|
batcher.logger.warn = warn;
|
|
63
68
|
});
|
|
64
69
|
|
|
65
|
-
it('returns true if no response in item', () =>
|
|
66
|
-
.then((res) => assert.isTrue(res)));
|
|
70
|
+
it('returns true if no response in item', () =>
|
|
71
|
+
batcher.didItemFail({}).then((res) => assert.isTrue(res)));
|
|
67
72
|
|
|
68
|
-
it('returns false, warns reqested size does not equal response size', () =>
|
|
69
|
-
|
|
73
|
+
it('returns false, warns reqested size does not equal response size', () =>
|
|
74
|
+
batcher
|
|
75
|
+
.didItemFail({size: 80, response: {size: 256}})
|
|
76
|
+
.then((res) => assert.isFalse(res && loggerWarned)));
|
|
70
77
|
|
|
71
|
-
it('returns false no warning', () =>
|
|
72
|
-
|
|
78
|
+
it('returns false no warning', () =>
|
|
79
|
+
batcher
|
|
80
|
+
.didItemFail({size: 80, response: {size: 80}})
|
|
81
|
+
.then((res) => assert.isFalse(res && !loggerWarned)));
|
|
73
82
|
});
|
|
74
83
|
});
|
|
75
84
|
});
|
|
@@ -9,31 +9,58 @@ import MockWebex from '@webex/test-helper-mock-webex';
|
|
|
9
9
|
/* eslint camelcase: 0 */
|
|
10
10
|
describe('plugin-avatar', () => {
|
|
11
11
|
const item1_40 = {
|
|
12
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
12
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
13
|
+
size: 40,
|
|
14
|
+
url: 'http://www-40.example.com',
|
|
15
|
+
cacheControl: 300,
|
|
13
16
|
};
|
|
14
17
|
const item1_50 = {
|
|
15
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
18
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
19
|
+
size: 50,
|
|
20
|
+
url: 'http://www-50.example.com',
|
|
21
|
+
cacheControl: 300,
|
|
16
22
|
};
|
|
17
23
|
const item1_80 = {
|
|
18
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
24
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
25
|
+
size: 80,
|
|
26
|
+
url: 'http://www-80.example.com',
|
|
27
|
+
cacheControl: 300,
|
|
19
28
|
};
|
|
20
29
|
const item1_110 = {
|
|
21
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
30
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
31
|
+
size: 110,
|
|
32
|
+
url: 'http://www-110.example.com',
|
|
33
|
+
cacheControl: 300,
|
|
22
34
|
};
|
|
23
35
|
const item1_192 = {
|
|
24
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
36
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
37
|
+
size: 192,
|
|
38
|
+
url: 'http://www-192.example.com',
|
|
39
|
+
cacheControl: 300,
|
|
25
40
|
};
|
|
26
41
|
const item1_640 = {
|
|
27
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
42
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
43
|
+
size: 640,
|
|
44
|
+
url: 'http://www-640.example.com',
|
|
45
|
+
cacheControl: 300,
|
|
28
46
|
};
|
|
29
47
|
const item1_1600 = {
|
|
30
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
48
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
49
|
+
size: 1600,
|
|
50
|
+
url: 'http://www-1600.example.com',
|
|
51
|
+
cacheControl: 300,
|
|
31
52
|
};
|
|
32
53
|
const item2_80 = {
|
|
33
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa1',
|
|
54
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa1',
|
|
55
|
+
size: 80,
|
|
56
|
+
url: 'http://www2.example.com',
|
|
57
|
+
cacheControl: 300,
|
|
34
58
|
};
|
|
35
59
|
const item3_80 = {
|
|
36
|
-
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa2',
|
|
60
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa2',
|
|
61
|
+
size: 80,
|
|
62
|
+
url: 'http://www3.example.com',
|
|
63
|
+
cacheControl: 300,
|
|
37
64
|
};
|
|
38
65
|
|
|
39
66
|
describe('AvatarUrlStore', () => {
|
|
@@ -43,60 +70,85 @@ describe('plugin-avatar', () => {
|
|
|
43
70
|
beforeEach(() => {
|
|
44
71
|
webex = new MockWebex({
|
|
45
72
|
children: {
|
|
46
|
-
avatar: Avatar
|
|
47
|
-
}
|
|
73
|
+
avatar: Avatar,
|
|
74
|
+
},
|
|
48
75
|
});
|
|
49
76
|
store = webex.internal.avatar.store;
|
|
50
77
|
});
|
|
51
78
|
|
|
52
|
-
it('add item failures', () =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
it('add item failures', () =>
|
|
80
|
+
Promise.all([
|
|
81
|
+
assert.isRejected(store.add(), '`item` is required'),
|
|
82
|
+
assert.isRejected(store.add({}), '`item.uuid` is required'),
|
|
83
|
+
assert.isRejected(store.add({uuid: 'id1'}), '`item.size` is required'),
|
|
84
|
+
assert.isRejected(
|
|
85
|
+
store.add({uuid: 'id1', size: 80}),
|
|
86
|
+
'`item.uuid` does not appear to be a uuid'
|
|
87
|
+
),
|
|
88
|
+
assert.isRejected(
|
|
89
|
+
store.add({uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0', size: 80}),
|
|
90
|
+
'`item.url` is required'
|
|
91
|
+
),
|
|
92
|
+
assert.isRejected(
|
|
93
|
+
store.add({
|
|
94
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
95
|
+
size: 80,
|
|
96
|
+
url: 'http://www.example.com',
|
|
97
|
+
}),
|
|
98
|
+
'`item.cacheControl` is required'
|
|
99
|
+
),
|
|
100
|
+
assert.isRejected(
|
|
101
|
+
store.add({
|
|
102
|
+
uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0',
|
|
103
|
+
size: 80,
|
|
104
|
+
url: 'http://www.example.com',
|
|
105
|
+
cacheControl: 0,
|
|
106
|
+
}),
|
|
107
|
+
'`item.cacheControl` is required'
|
|
108
|
+
),
|
|
109
|
+
]));
|
|
63
110
|
|
|
64
|
-
it('get item failures', () =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
111
|
+
it('get item failures', () =>
|
|
112
|
+
Promise.all([
|
|
113
|
+
assert.isRejected(store.get(), '`item` is required'),
|
|
114
|
+
assert.isRejected(store.get({}), '`item.uuid` is required'),
|
|
115
|
+
assert.isRejected(store.get({uuid: 'id1'}), '`item.size` is required'),
|
|
116
|
+
assert.isRejected(
|
|
117
|
+
store.get({uuid: 'id1', size: 80}),
|
|
118
|
+
'`item.uuid` does not appear to be a uuid'
|
|
119
|
+
),
|
|
120
|
+
assert.isRejected(
|
|
121
|
+
store.get({uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0', size: 80}),
|
|
122
|
+
'No URL found by specified id'
|
|
123
|
+
),
|
|
124
|
+
]));
|
|
71
125
|
|
|
72
|
-
it('set / get / remove', () =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.then((result) => assert.deepEqual(result, item1_80)),
|
|
78
|
-
|
|
79
|
-
.then((result) => assert.deepEqual(result,
|
|
80
|
-
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
assert.isRejected(store.get(item1_1600))
|
|
100
|
-
]));
|
|
126
|
+
it('set / get / remove', () =>
|
|
127
|
+
Promise.all([
|
|
128
|
+
store.add(item1_80),
|
|
129
|
+
store.add(item2_80),
|
|
130
|
+
store.add(item3_80),
|
|
131
|
+
store.get(item1_80).then((result) => assert.deepEqual(result, item1_80)),
|
|
132
|
+
store.get(item2_80).then((result) => assert.deepEqual(result, item2_80)),
|
|
133
|
+
store.get(item3_80).then((result) => assert.deepEqual(result, item3_80)),
|
|
134
|
+
store.remove(item2_80),
|
|
135
|
+
store.remove(item3_80),
|
|
136
|
+
assert.isRejected(store.get(item3_80)),
|
|
137
|
+
assert.isRejected(store.get(item2_80)),
|
|
138
|
+
store.add(item1_40),
|
|
139
|
+
store.add(item1_50),
|
|
140
|
+
store.add(item1_110),
|
|
141
|
+
store.add(item1_192),
|
|
142
|
+
store.add(item1_640),
|
|
143
|
+
store.add(item1_1600),
|
|
144
|
+
store.remove({uuid: '88888888-4444-4444-4444-aaaaaaaaaaa0'}),
|
|
145
|
+
assert.isRejected(store.get(item1_40)),
|
|
146
|
+
assert.isRejected(store.get(item1_50)),
|
|
147
|
+
assert.isRejected(store.get(item1_80)),
|
|
148
|
+
assert.isRejected(store.get(item1_110)),
|
|
149
|
+
assert.isRejected(store.get(item1_192)),
|
|
150
|
+
assert.isRejected(store.get(item1_640)),
|
|
151
|
+
assert.isRejected(store.get(item1_1600)),
|
|
152
|
+
]));
|
|
101
153
|
});
|
|
102
154
|
});
|