@webex/internal-plugin-calendar 3.0.0-beta.2 → 3.0.0-beta.200

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.
@@ -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 {CALENDAR_REGISTERED, CALENDAR_UPDATED, CALENDAR_DELETE, CALENDAR_CREATE, CALENDAR_UNREGISTERED} from '../../../src/constants';
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.stub().returns(Promise.resolve({body: {items: [{id: 'calendar1'}, {id: 'calendar2'}]}})); webex.request = sinon.stub().returns(
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
- {id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
116
- {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
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
- {id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
140
- {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
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,27 @@ describe('internal-plugin-calendar', () => {
157
182
  const webexRequestStub = sinon.stub();
158
183
 
159
184
  // calendar list stub
160
- webexRequestStub.withArgs({
161
- method: 'GET',
162
- service: 'calendar',
163
- resource: 'calendarEvents',
164
- qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
165
- }).returns(
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
- );
175
- // getNotes stub
176
- webexRequestStub.withArgs({
177
- method: 'GET',
178
- service: 'calendar',
179
- resource: `calendarEvents/${btoa('calendar1')}/notes`
180
- }).returns(
181
- Promise.resolve({
182
- body: null
183
- })
184
- );
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
+ );
185
206
 
186
207
  // Assign webexRequestStub to webex.request
187
208
  webex.request = webexRequestStub;
@@ -190,19 +211,14 @@ describe('internal-plugin-calendar', () => {
190
211
 
191
212
  assert.equal(res.length, 2);
192
213
  assert.deepEqual(res, [
193
- {id: 'calendar1', encryptedNotes: null, encryptedParticipants: ['participant1']},
194
- {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
214
+ {id: 'calendar1', encryptedParticipants: ['participant1']},
215
+ {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
195
216
  ]);
196
217
  assert.calledWith(webex.request, {
197
218
  method: 'GET',
198
219
  service: 'calendar',
199
220
  resource: 'calendarEvents',
200
- qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
201
- });
202
- assert.calledWith(webex.request, {
203
- method: 'GET',
204
- service: 'calendar',
205
- resource: `calendarEvents/${btoa('calendar1')}/notes`
221
+ qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
206
222
  });
207
223
  });
208
224
 
@@ -210,33 +226,27 @@ describe('internal-plugin-calendar', () => {
210
226
  const webexRequestStub = sinon.stub();
211
227
 
212
228
  // calendar list stub
213
- webexRequestStub.withArgs({
214
- method: 'GET',
215
- service: 'calendar',
216
- resource: 'calendarEvents',
217
- qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
218
- }).returns(
219
- Promise.resolve({
220
- body: {
221
- items: [
222
- {id: 'calendar1', encryptedParticipants: ['participant1']},
223
- {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
224
- ]
225
- }
229
+ webexRequestStub
230
+ .withArgs({
231
+ method: 'GET',
232
+ service: 'calendar',
233
+ resource: 'calendarEvents',
234
+ qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
226
235
  })
227
- );
228
- // getNotes stub
229
- webexRequestStub.withArgs({
230
- method: 'GET',
231
- service: 'calendar',
232
- resource: `calendarEvents/${btoa('calendar1')}/notes`
233
- }).returns(
234
- Promise.resolve({
235
- body: {
236
- encryptedNotes: 'notes1'
237
- }
238
- })
239
- );
236
+ .returns(
237
+ Promise.resolve({
238
+ body: {
239
+ items: [
240
+ {id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
241
+ {
242
+ id: 'calendar2',
243
+ encryptedNotes: 'notes2',
244
+ encryptedParticipants: ['participant2'],
245
+ },
246
+ ],
247
+ },
248
+ })
249
+ );
240
250
 
241
251
  // Assign webexRequestStub to webex.request
242
252
  webex.request = webexRequestStub;
@@ -246,18 +256,13 @@ describe('internal-plugin-calendar', () => {
246
256
  assert.equal(res.length, 2);
247
257
  assert.deepEqual(res, [
248
258
  {id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
249
- {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
259
+ {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
250
260
  ]);
251
261
  assert.calledWith(webex.request, {
252
262
  method: 'GET',
253
263
  service: 'calendar',
254
264
  resource: 'calendarEvents',
255
- qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
256
- });
257
- assert.calledWith(webex.request, {
258
- method: 'GET',
259
- service: 'calendar',
260
- resource: `calendarEvents/${btoa('calendar1')}/notes`
265
+ qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
261
266
  });
262
267
  });
263
268
  });
@@ -269,8 +274,8 @@ describe('internal-plugin-calendar', () => {
269
274
  webex.request = sinon.stub().returns(
270
275
  Promise.resolve({
271
276
  body: {
272
- encryptedNotes: 'notes1'
273
- }
277
+ encryptedNotes: 'notes1',
278
+ },
274
279
  })
275
280
  );
276
281
 
@@ -280,30 +285,51 @@ describe('internal-plugin-calendar', () => {
280
285
  assert.calledWith(webex.request, {
281
286
  method: 'GET',
282
287
  service: 'calendar',
283
- resource: `calendarEvents/${btoa(id)}/notes`
288
+ resource: `calendarEvents/${btoa(id)}/notes`,
284
289
  });
285
290
  });
286
291
  });
287
292
 
288
293
  describe('#getParticipants()', () => {
289
- const id = 'meetingId123';
294
+ const uri = 'participantsUrl';
290
295
 
291
296
  it('should fetch the meeting participants', async () => {
292
297
  webex.request = sinon.stub().returns(
293
298
  Promise.resolve({
294
299
  body: {
295
- encryptedParticipants: ['participant1']
296
- }
300
+ encryptedParticipants: ['participant1'],
301
+ },
297
302
  })
298
303
  );
299
304
 
300
- const res = await webex.internal.calendar.getParticipants(id);
305
+ const res = await webex.internal.calendar.getParticipants(uri);
301
306
 
302
307
  assert.equal(res.body.encryptedParticipants.length, 1);
303
308
  assert.calledWith(webex.request, {
304
309
  method: 'GET',
305
- service: 'calendar',
306
- resource: `calendarEvents/${btoa(id)}/participants`
310
+ uri,
311
+ });
312
+ });
313
+ });
314
+
315
+ describe('#getNotesByUrl()', () => {
316
+ const uri = 'notesUrl';
317
+
318
+ it('should fetch the meeting notes', async () => {
319
+ webex.request = sinon.stub().returns(
320
+ Promise.resolve({
321
+ body: {
322
+ encryptedParticipants: ['participant1'],
323
+ },
324
+ })
325
+ );
326
+
327
+ const res = await webex.internal.calendar.getNotesByUrl(uri);
328
+
329
+ assert.equal(res.body.encryptedParticipants.length, 1);
330
+ assert.calledWith(webex.request, {
331
+ method: 'GET',
332
+ uri,
307
333
  });
308
334
  });
309
335
  });
@@ -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({start: '2020-02-21T18:57:00.000Z', durationMinutes: 30});
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
  });