@webex/internal-plugin-calendar 3.0.0-beta.4 → 3.0.0-beta.40
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/calendar.js +20 -61
- package/dist/calendar.js.map +1 -1
- package/dist/collection.js +0 -19
- package/dist/collection.js.map +1 -1
- package/dist/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js +7 -21
- package/dist/index.js.map +1 -1
- package/dist/util.js +0 -13
- package/dist/util.js.map +1 -1
- package/package.json +10 -10
- package/src/calendar.js +47 -42
- package/src/collection.js +2 -4
- package/src/config.js +2 -2
- package/src/index.js +97 -40
- package/src/util.js +5 -3
- package/test/integration/spec/calendar.js +379 -271
- package/test/unit/spec/calendar.js +115 -74
- package/test/unit/spec/utils.js +4 -1
|
@@ -8,7 +8,13 @@ import MockWebex from '@webex/test-helper-mock-webex';
|
|
|
8
8
|
import btoa from 'btoa';
|
|
9
9
|
import sinon from 'sinon';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
CALENDAR_REGISTERED,
|
|
13
|
+
CALENDAR_UPDATED,
|
|
14
|
+
CALENDAR_DELETE,
|
|
15
|
+
CALENDAR_CREATE,
|
|
16
|
+
CALENDAR_UNREGISTERED,
|
|
17
|
+
} from '../../../src/constants';
|
|
12
18
|
|
|
13
19
|
describe('internal-plugin-calendar', () => {
|
|
14
20
|
describe('Calendar Apis', () => {
|
|
@@ -17,14 +23,14 @@ describe('internal-plugin-calendar', () => {
|
|
|
17
23
|
beforeEach(async () => {
|
|
18
24
|
webex = new MockWebex({
|
|
19
25
|
children: {
|
|
20
|
-
calendar: Calendar
|
|
21
|
-
}
|
|
26
|
+
calendar: Calendar,
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
|
|
24
30
|
webex.canAuthorize = true;
|
|
25
31
|
webex.internal.device = {
|
|
26
32
|
register: sinon.stub().returns(Promise.resolve()),
|
|
27
|
-
unregister: sinon.stub().returns(Promise.resolve())
|
|
33
|
+
unregister: sinon.stub().returns(Promise.resolve()),
|
|
28
34
|
};
|
|
29
35
|
webex.internal.mercury = {
|
|
30
36
|
connect: sinon.stub().returns(Promise.resolve()),
|
|
@@ -40,7 +46,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
40
46
|
callback({data: {calendarMeetingExternal: {id: 'calendarId1'}}});
|
|
41
47
|
}
|
|
42
48
|
}),
|
|
43
|
-
off: sinon.spy()
|
|
49
|
+
off: sinon.spy(),
|
|
44
50
|
};
|
|
45
51
|
});
|
|
46
52
|
|
|
@@ -108,14 +114,25 @@ describe('internal-plugin-calendar', () => {
|
|
|
108
114
|
|
|
109
115
|
describe('#syncCalendar()', () => {
|
|
110
116
|
it('should sync from calendar service', async () => {
|
|
111
|
-
webex.request = sinon
|
|
117
|
+
webex.request = sinon
|
|
118
|
+
.stub()
|
|
119
|
+
.returns(Promise.resolve({body: {items: [{id: 'calendar1'}, {id: 'calendar2'}]}}));
|
|
120
|
+
webex.request = sinon.stub().returns(
|
|
112
121
|
Promise.resolve({
|
|
113
122
|
body: {
|
|
114
123
|
items: [
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
{
|
|
125
|
+
id: 'calendar1',
|
|
126
|
+
encryptedNotes: 'notes1',
|
|
127
|
+
encryptedParticipants: ['participant1'],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'calendar2',
|
|
131
|
+
encryptedNotes: 'notes2',
|
|
132
|
+
encryptedParticipants: ['participant2'],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
119
136
|
})
|
|
120
137
|
);
|
|
121
138
|
await webex.internal.calendar.syncCalendar({fromDate: 'xx-xx', toDate: 'xx-nn'});
|
|
@@ -123,7 +140,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
123
140
|
method: 'GET',
|
|
124
141
|
service: 'calendar',
|
|
125
142
|
resource: 'calendarEvents',
|
|
126
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
143
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
127
144
|
});
|
|
128
145
|
assert.equal(webex.internal.calendar.getAll().length, 2);
|
|
129
146
|
assert.equal(webex.internal.calendar.getAll()[0].id, 'calendar1');
|
|
@@ -136,10 +153,18 @@ describe('internal-plugin-calendar', () => {
|
|
|
136
153
|
Promise.resolve({
|
|
137
154
|
body: {
|
|
138
155
|
items: [
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
{
|
|
157
|
+
id: 'calendar1',
|
|
158
|
+
encryptedNotes: 'notes1',
|
|
159
|
+
encryptedParticipants: ['participant1'],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'calendar2',
|
|
163
|
+
encryptedNotes: 'notes2',
|
|
164
|
+
encryptedParticipants: ['participant2'],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
143
168
|
})
|
|
144
169
|
);
|
|
145
170
|
const res = await webex.internal.calendar.list({fromDate: 'xx-xx', toDate: 'xx-nn'});
|
|
@@ -149,7 +174,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
149
174
|
method: 'GET',
|
|
150
175
|
service: 'calendar',
|
|
151
176
|
resource: 'calendarEvents',
|
|
152
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
177
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
153
178
|
});
|
|
154
179
|
});
|
|
155
180
|
|
|
@@ -157,31 +182,39 @@ describe('internal-plugin-calendar', () => {
|
|
|
157
182
|
const webexRequestStub = sinon.stub();
|
|
158
183
|
|
|
159
184
|
// calendar list stub
|
|
160
|
-
webexRequestStub
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Promise.resolve({
|
|
167
|
-
body: {
|
|
168
|
-
items: [
|
|
169
|
-
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
170
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
171
|
-
]
|
|
172
|
-
}
|
|
185
|
+
webexRequestStub
|
|
186
|
+
.withArgs({
|
|
187
|
+
method: 'GET',
|
|
188
|
+
service: 'calendar',
|
|
189
|
+
resource: 'calendarEvents',
|
|
190
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
173
191
|
})
|
|
174
|
-
|
|
192
|
+
.returns(
|
|
193
|
+
Promise.resolve({
|
|
194
|
+
body: {
|
|
195
|
+
items: [
|
|
196
|
+
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
197
|
+
{
|
|
198
|
+
id: 'calendar2',
|
|
199
|
+
encryptedNotes: 'notes2',
|
|
200
|
+
encryptedParticipants: ['participant2'],
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
})
|
|
205
|
+
);
|
|
175
206
|
// getNotes stub
|
|
176
|
-
webexRequestStub
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Promise.resolve({
|
|
182
|
-
body: null
|
|
207
|
+
webexRequestStub
|
|
208
|
+
.withArgs({
|
|
209
|
+
method: 'GET',
|
|
210
|
+
service: 'calendar',
|
|
211
|
+
resource: `calendarEvents/${btoa('calendar1')}/notes`,
|
|
183
212
|
})
|
|
184
|
-
|
|
213
|
+
.returns(
|
|
214
|
+
Promise.resolve({
|
|
215
|
+
body: null,
|
|
216
|
+
})
|
|
217
|
+
);
|
|
185
218
|
|
|
186
219
|
// Assign webexRequestStub to webex.request
|
|
187
220
|
webex.request = webexRequestStub;
|
|
@@ -191,18 +224,18 @@ describe('internal-plugin-calendar', () => {
|
|
|
191
224
|
assert.equal(res.length, 2);
|
|
192
225
|
assert.deepEqual(res, [
|
|
193
226
|
{id: 'calendar1', encryptedNotes: null, encryptedParticipants: ['participant1']},
|
|
194
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
227
|
+
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
|
|
195
228
|
]);
|
|
196
229
|
assert.calledWith(webex.request, {
|
|
197
230
|
method: 'GET',
|
|
198
231
|
service: 'calendar',
|
|
199
232
|
resource: 'calendarEvents',
|
|
200
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
233
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
201
234
|
});
|
|
202
235
|
assert.calledWith(webex.request, {
|
|
203
236
|
method: 'GET',
|
|
204
237
|
service: 'calendar',
|
|
205
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes
|
|
238
|
+
resource: `calendarEvents/${btoa('calendar1')}/notes`,
|
|
206
239
|
});
|
|
207
240
|
});
|
|
208
241
|
|
|
@@ -210,33 +243,41 @@ describe('internal-plugin-calendar', () => {
|
|
|
210
243
|
const webexRequestStub = sinon.stub();
|
|
211
244
|
|
|
212
245
|
// calendar list stub
|
|
213
|
-
webexRequestStub
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Promise.resolve({
|
|
220
|
-
body: {
|
|
221
|
-
items: [
|
|
222
|
-
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
223
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
224
|
-
]
|
|
225
|
-
}
|
|
246
|
+
webexRequestStub
|
|
247
|
+
.withArgs({
|
|
248
|
+
method: 'GET',
|
|
249
|
+
service: 'calendar',
|
|
250
|
+
resource: 'calendarEvents',
|
|
251
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
226
252
|
})
|
|
227
|
-
|
|
253
|
+
.returns(
|
|
254
|
+
Promise.resolve({
|
|
255
|
+
body: {
|
|
256
|
+
items: [
|
|
257
|
+
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
258
|
+
{
|
|
259
|
+
id: 'calendar2',
|
|
260
|
+
encryptedNotes: 'notes2',
|
|
261
|
+
encryptedParticipants: ['participant2'],
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
);
|
|
228
267
|
// getNotes stub
|
|
229
|
-
webexRequestStub
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Promise.resolve({
|
|
235
|
-
body: {
|
|
236
|
-
encryptedNotes: 'notes1'
|
|
237
|
-
}
|
|
268
|
+
webexRequestStub
|
|
269
|
+
.withArgs({
|
|
270
|
+
method: 'GET',
|
|
271
|
+
service: 'calendar',
|
|
272
|
+
resource: `calendarEvents/${btoa('calendar1')}/notes`,
|
|
238
273
|
})
|
|
239
|
-
|
|
274
|
+
.returns(
|
|
275
|
+
Promise.resolve({
|
|
276
|
+
body: {
|
|
277
|
+
encryptedNotes: 'notes1',
|
|
278
|
+
},
|
|
279
|
+
})
|
|
280
|
+
);
|
|
240
281
|
|
|
241
282
|
// Assign webexRequestStub to webex.request
|
|
242
283
|
webex.request = webexRequestStub;
|
|
@@ -246,18 +287,18 @@ describe('internal-plugin-calendar', () => {
|
|
|
246
287
|
assert.equal(res.length, 2);
|
|
247
288
|
assert.deepEqual(res, [
|
|
248
289
|
{id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
|
|
249
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
290
|
+
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
|
|
250
291
|
]);
|
|
251
292
|
assert.calledWith(webex.request, {
|
|
252
293
|
method: 'GET',
|
|
253
294
|
service: 'calendar',
|
|
254
295
|
resource: 'calendarEvents',
|
|
255
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
296
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
256
297
|
});
|
|
257
298
|
assert.calledWith(webex.request, {
|
|
258
299
|
method: 'GET',
|
|
259
300
|
service: 'calendar',
|
|
260
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes
|
|
301
|
+
resource: `calendarEvents/${btoa('calendar1')}/notes`,
|
|
261
302
|
});
|
|
262
303
|
});
|
|
263
304
|
});
|
|
@@ -269,8 +310,8 @@ describe('internal-plugin-calendar', () => {
|
|
|
269
310
|
webex.request = sinon.stub().returns(
|
|
270
311
|
Promise.resolve({
|
|
271
312
|
body: {
|
|
272
|
-
encryptedNotes: 'notes1'
|
|
273
|
-
}
|
|
313
|
+
encryptedNotes: 'notes1',
|
|
314
|
+
},
|
|
274
315
|
})
|
|
275
316
|
);
|
|
276
317
|
|
|
@@ -280,7 +321,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
280
321
|
assert.calledWith(webex.request, {
|
|
281
322
|
method: 'GET',
|
|
282
323
|
service: 'calendar',
|
|
283
|
-
resource: `calendarEvents/${btoa(id)}/notes
|
|
324
|
+
resource: `calendarEvents/${btoa(id)}/notes`,
|
|
284
325
|
});
|
|
285
326
|
});
|
|
286
327
|
});
|
|
@@ -292,8 +333,8 @@ describe('internal-plugin-calendar', () => {
|
|
|
292
333
|
webex.request = sinon.stub().returns(
|
|
293
334
|
Promise.resolve({
|
|
294
335
|
body: {
|
|
295
|
-
encryptedParticipants: ['participant1']
|
|
296
|
-
}
|
|
336
|
+
encryptedParticipants: ['participant1'],
|
|
337
|
+
},
|
|
297
338
|
})
|
|
298
339
|
);
|
|
299
340
|
|
|
@@ -303,7 +344,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
303
344
|
assert.calledWith(webex.request, {
|
|
304
345
|
method: 'GET',
|
|
305
346
|
service: 'calendar',
|
|
306
|
-
resource: `calendarEvents/${btoa(id)}/participants
|
|
347
|
+
resource: `calendarEvents/${btoa(id)}/participants`,
|
|
307
348
|
});
|
|
308
349
|
});
|
|
309
350
|
});
|
package/test/unit/spec/utils.js
CHANGED
|
@@ -5,7 +5,10 @@ import CalendarUtils from '../../../src/util';
|
|
|
5
5
|
describe('Calendar utils', () => {
|
|
6
6
|
describe('#calculateEndTime()', () => {
|
|
7
7
|
it('return the end time for meeting', () => {
|
|
8
|
-
const result = CalendarUtils.calculateEndTime({
|
|
8
|
+
const result = CalendarUtils.calculateEndTime({
|
|
9
|
+
start: '2020-02-21T18:57:00.000Z',
|
|
10
|
+
durationMinutes: 30,
|
|
11
|
+
});
|
|
9
12
|
|
|
10
13
|
assert.equal(new Date(result.endTime).toISOString(), '2020-02-21T19:27:00.000Z');
|
|
11
14
|
});
|