@webex/internal-plugin-avatar 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.
- package/README.md +1 -3
- package/dist/avatar-url-batcher.js +5 -17
- package/dist/avatar-url-batcher.js.map +1 -1
- package/dist/avatar-url-store.js +4 -31
- package/dist/avatar-url-store.js.map +1 -1
- package/dist/avatar.js +8 -32
- package/dist/avatar.js.map +1 -1
- package/dist/config.js +0 -7
- package/dist/config.js.map +1 -1
- package/dist/index.js +1 -9
- 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
|
@@ -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
|
});
|