@webex/internal-plugin-conversation 3.0.0-beta.9 → 3.0.0-bnr.2

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.
Files changed (57) hide show
  1. package/README.md +1 -3
  2. package/dist/activities.js +8 -69
  3. package/dist/activities.js.map +1 -1
  4. package/dist/activity-thread-ordering.js +19 -79
  5. package/dist/activity-thread-ordering.js.map +1 -1
  6. package/dist/config.js +1 -7
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +4 -5
  9. package/dist/constants.js.map +1 -1
  10. package/dist/conversation.js +790 -1199
  11. package/dist/conversation.js.map +1 -1
  12. package/dist/convo-error.js +0 -23
  13. package/dist/convo-error.js.map +1 -1
  14. package/dist/decryption-transforms.js +35 -98
  15. package/dist/decryption-transforms.js.map +1 -1
  16. package/dist/encryption-transforms.js +11 -48
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +7 -50
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal-plugin-conversation.d.ts +21 -0
  21. package/dist/share-activity.js +40 -106
  22. package/dist/share-activity.js.map +1 -1
  23. package/dist/to-array.js +9 -11
  24. package/dist/to-array.js.map +1 -1
  25. package/dist/tsdoc-metadata.json +11 -0
  26. package/dist/types/activities.d.ts +32 -0
  27. package/dist/types/activity-thread-ordering.d.ts +18 -0
  28. package/dist/types/config.d.ts +19 -0
  29. package/dist/types/constants.d.ts +5 -0
  30. package/dist/types/conversation.d.ts +2 -0
  31. package/dist/types/convo-error.d.ts +10 -0
  32. package/dist/types/decryption-transforms.d.ts +1 -0
  33. package/dist/types/encryption-transforms.d.ts +1 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/share-activity.d.ts +7 -0
  36. package/dist/types/to-array.d.ts +9 -0
  37. package/package.json +15 -15
  38. package/src/activities.js +10 -7
  39. package/src/activity-thread-ordering.js +27 -30
  40. package/src/activity-threading.md +68 -49
  41. package/src/config.js +5 -5
  42. package/src/conversation.js +621 -589
  43. package/src/decryption-transforms.js +103 -62
  44. package/src/encryption-transforms.js +103 -83
  45. package/src/index.js +82 -66
  46. package/src/share-activity.js +64 -55
  47. package/src/to-array.js +2 -2
  48. package/test/integration/spec/create.js +184 -118
  49. package/test/integration/spec/encryption.js +250 -186
  50. package/test/integration/spec/get.js +761 -513
  51. package/test/integration/spec/mercury.js +37 -27
  52. package/test/integration/spec/share.js +292 -229
  53. package/test/integration/spec/verbs.js +628 -441
  54. package/test/unit/spec/conversation.js +265 -163
  55. package/test/unit/spec/decrypt-transforms.js +112 -131
  56. package/test/unit/spec/encryption-transforms.js +24 -18
  57. package/test/unit/spec/share-activity.js +37 -40
@@ -21,8 +21,7 @@ import {flaky, skipInNode, browserOnly} from '@webex/test-helper-mocha';
21
21
  * @returns {Promise<mixed>}
22
22
  */
23
23
  function returnFirstArg(fn) {
24
- return (result) => Promise.resolve(fn(result))
25
- .then(() => result);
24
+ return (result) => Promise.resolve(fn(result)).then(() => result);
26
25
  }
27
26
 
28
27
  describe('plugin-conversation', function () {
@@ -30,8 +29,8 @@ describe('plugin-conversation', function () {
30
29
  describe('share', () => {
31
30
  let mccoy, participants, webex, spock;
32
31
 
33
- before(() => testUsers.create({count: 3})
34
- .then(async (users) => {
32
+ before(() =>
33
+ testUsers.create({count: 3}).then(async (users) => {
35
34
  participants = users;
36
35
  [spock, mccoy] = participants;
37
36
 
@@ -40,26 +39,29 @@ describe('plugin-conversation', function () {
40
39
 
41
40
  webex = new WebexCore({
42
41
  credentials: {
43
- authorization: spock.token
44
- }
42
+ authorization: spock.token,
43
+ },
45
44
  });
46
45
 
47
46
  mccoy.webex = new WebexCore({
48
47
  credentials: {
49
- authorization: mccoy.token
50
- }
48
+ authorization: mccoy.token,
49
+ },
51
50
  });
52
51
 
53
52
  return Promise.all([
54
53
  webex.internal.mercury.connect(),
55
- mccoy.webex.internal.mercury.connect()
54
+ mccoy.webex.internal.mercury.connect(),
56
55
  ]);
57
- }));
56
+ })
57
+ );
58
58
 
59
- after(() => Promise.all([
60
- webex && webex.internal.mercury.disconnect(),
61
- mccoy && mccoy.webex.internal.mercury.disconnect()
62
- ]));
59
+ after(() =>
60
+ Promise.all([
61
+ webex && webex.internal.mercury.disconnect(),
62
+ mccoy && mccoy.webex.internal.mercury.disconnect(),
63
+ ])
64
+ );
63
65
 
64
66
  let conversation;
65
67
 
@@ -68,8 +70,9 @@ describe('plugin-conversation', function () {
68
70
  return Promise.resolve();
69
71
  }
70
72
 
71
- return webex.internal.conversation.create({participants})
72
- .then((c) => { conversation = c; });
73
+ return webex.internal.conversation.create({participants}).then((c) => {
74
+ conversation = c;
75
+ });
73
76
  });
74
77
 
75
78
  let hashTestText = '#test.txt';
@@ -82,17 +85,17 @@ describe('plugin-conversation', function () {
82
85
  let sampleTextTwo = 'sample-text-two.txt';
83
86
  const sampleGif = 'sample-gif.gif';
84
87
 
85
- before(() => Promise.all([
86
- fh.fetchWithoutMagic(hashTestText),
87
- fh.fetchWithoutMagic(sampleImageSmallOnePng),
88
- fh.fetchWithoutMagic(sampleImageSmallTwoPng),
89
- fh.fetchWithoutMagic(sampleImageLargeJpg),
90
- fh.fetchWithoutMagic(sampleImageLargeNoEXIFJpg),
91
- fh.fetchWithoutMagic(samplePowerpointTwoPagePpt),
92
- fh.fetchWithoutMagic(sampleTextOne),
93
- fh.fetchWithoutMagic(sampleTextTwo)
94
- ])
95
- .then((res) => {
88
+ before(() =>
89
+ Promise.all([
90
+ fh.fetchWithoutMagic(hashTestText),
91
+ fh.fetchWithoutMagic(sampleImageSmallOnePng),
92
+ fh.fetchWithoutMagic(sampleImageSmallTwoPng),
93
+ fh.fetchWithoutMagic(sampleImageLargeJpg),
94
+ fh.fetchWithoutMagic(sampleImageLargeNoEXIFJpg),
95
+ fh.fetchWithoutMagic(samplePowerpointTwoPagePpt),
96
+ fh.fetchWithoutMagic(sampleTextOne),
97
+ fh.fetchWithoutMagic(sampleTextTwo),
98
+ ]).then((res) => {
96
99
  [
97
100
  hashTestText,
98
101
  sampleImageSmallOnePng,
@@ -101,46 +104,15 @@ describe('plugin-conversation', function () {
101
104
  sampleImageLargeNoEXIFJpg,
102
105
  samplePowerpointTwoPagePpt,
103
106
  sampleTextOne,
104
- sampleTextTwo
107
+ sampleTextTwo,
105
108
  ] = res;
106
- }));
109
+ })
110
+ );
107
111
 
108
112
  describe('#share()', () => {
109
- it('shares the specified file to the specified conversation', () => webex.internal.conversation.share(conversation, [sampleTextOne])
110
- .then((activity) => {
111
- assert.isActivity(activity);
112
- assert.isEncryptedActivity(activity);
113
- assert.isFileItem(activity.object.files.items[0]);
114
-
115
- return webex.internal.conversation.download(activity.object.files.items[0]);
116
- })
117
- .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
118
- .then((f) => fh.isMatchingFile(f, sampleTextOne)
119
- .then((result) => assert.isTrue(result))));
120
-
121
- it('shares the specified set of files to the specified conversation', () => webex.internal.conversation.share(conversation, [sampleTextOne, sampleTextTwo])
122
- .then((activity) => {
123
- assert.isActivity(activity);
124
- assert.isEncryptedActivity(activity);
125
- assert.isFileItem(activity.object.files.items[0]);
126
- assert.isFileItem(activity.object.files.items[1]);
127
-
128
- return Promise.all([
129
- webex.internal.conversation.download(activity.object.files.items[0])
130
- .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
131
- webex.internal.conversation.download(activity.object.files.items[1])
132
- .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
133
- ]);
134
- })
135
- .then(([file0, file1]) => Promise.all([
136
- fh.isMatchingFile(file0, sampleTextOne)
137
- .then((result) => assert.isTrue(result)),
138
- fh.isMatchingFile(file1, sampleTextTwo)
139
- .then((result) => assert.isTrue(result))
140
- ])));
141
-
142
- describe('files with special characters', () => {
143
- it('shares the specified file to the specified conversation', () => webex.internal.conversation.share(conversation, [hashTestText])
113
+ it('shares the specified file to the specified conversation', () =>
114
+ webex.internal.conversation
115
+ .share(conversation, [sampleTextOne])
144
116
  .then((activity) => {
145
117
  assert.isActivity(activity);
146
118
  assert.isEncryptedActivity(activity);
@@ -148,82 +120,138 @@ describe('plugin-conversation', function () {
148
120
 
149
121
  return webex.internal.conversation.download(activity.object.files.items[0]);
150
122
  })
151
- // in node, this'll be 'text/plain', in a browser, it'll be
152
- // 'text/html'. I'm pretty sure it's caused by the # convincing
153
- // express it's a hashroute and treating it as html. The discrepancy
154
- // has no bearing on the test's validity. Further, we need to use
155
- // match rather than equal because some browser append the charset.
156
- .then(returnFirstArg((f) => assert.match(f.type, hashTestText.type || /text\/plain/)))
157
- .then((f) => fh.isMatchingFile(f, hashTestText)
158
- .then((result) => assert.isTrue(result))));
159
- });
123
+ .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
124
+ .then((f) =>
125
+ fh.isMatchingFile(f, sampleTextOne).then((result) => assert.isTrue(result))
126
+ ));
127
+
128
+ it('shares the specified set of files to the specified conversation', () =>
129
+ webex.internal.conversation
130
+ .share(conversation, [sampleTextOne, sampleTextTwo])
131
+ .then((activity) => {
132
+ assert.isActivity(activity);
133
+ assert.isEncryptedActivity(activity);
134
+ assert.isFileItem(activity.object.files.items[0]);
135
+ assert.isFileItem(activity.object.files.items[1]);
136
+
137
+ return Promise.all([
138
+ webex.internal.conversation
139
+ .download(activity.object.files.items[0])
140
+ .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
141
+ webex.internal.conversation
142
+ .download(activity.object.files.items[1])
143
+ .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
144
+ ]);
145
+ })
146
+ .then(([file0, file1]) =>
147
+ Promise.all([
148
+ fh.isMatchingFile(file0, sampleTextOne).then((result) => assert.isTrue(result)),
149
+ fh.isMatchingFile(file1, sampleTextTwo).then((result) => assert.isTrue(result)),
150
+ ])
151
+ ));
160
152
 
161
- it('shares an image with no EXIF data to the specified conversation and correctly error handles', () => webex.internal.conversation.share(conversation, [sampleImageLargeNoEXIFJpg])
162
- .then((activity) => {
163
- assert.isActivity(activity);
164
- assert.isEncryptedActivity(activity);
153
+ describe('files with special characters', () => {
154
+ it('shares the specified file to the specified conversation', () =>
155
+ webex.internal.conversation
156
+ .share(conversation, [hashTestText])
157
+ .then((activity) => {
158
+ assert.isActivity(activity);
159
+ assert.isEncryptedActivity(activity);
160
+ assert.isFileItem(activity.object.files.items[0]);
161
+
162
+ return webex.internal.conversation.download(activity.object.files.items[0]);
163
+ })
164
+ // in node, this'll be 'text/plain', in a browser, it'll be
165
+ // 'text/html'. I'm pretty sure it's caused by the # convincing
166
+ // express it's a hashroute and treating it as html. The discrepancy
167
+ // has no bearing on the test's validity. Further, we need to use
168
+ // match rather than equal because some browser append the charset.
169
+ .then(returnFirstArg((f) => assert.match(f.type, hashTestText.type || /text\/plain/)))
170
+ .then((f) =>
171
+ fh.isMatchingFile(f, hashTestText).then((result) => assert.isTrue(result))
172
+ ));
173
+ });
165
174
 
166
- const fileItem = activity.object.files.items[0];
175
+ it('shares an image with no EXIF data to the specified conversation and correctly error handles', () =>
176
+ webex.internal.conversation
177
+ .share(conversation, [sampleImageLargeNoEXIFJpg])
178
+ .then((activity) => {
179
+ assert.isActivity(activity);
180
+ assert.isEncryptedActivity(activity);
167
181
 
168
- assert.isFileItem(fileItem);
182
+ const fileItem = activity.object.files.items[0];
169
183
 
170
- const thumbnailItem = activity.object.files.items[0].image;
184
+ assert.isFileItem(fileItem);
171
185
 
172
- assert.isThumbnailItem(thumbnailItem);
173
- assert.equal(thumbnailItem.width, 640);
174
- assert.isAbove(thumbnailItem.height, 358);
175
- assert.isBelow(thumbnailItem.height, 361);
186
+ const thumbnailItem = activity.object.files.items[0].image;
176
187
 
177
- return webex.internal.conversation.download(activity.object.files.items[0]);
178
- })
179
- .then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
180
- .then((f) => fh.isMatchingFile(f, sampleImageLargeNoEXIFJpg)
181
- .then((result) => assert.isTrue(result))));
188
+ assert.isThumbnailItem(thumbnailItem);
189
+ assert.equal(thumbnailItem.width, 640);
190
+ assert.isAbove(thumbnailItem.height, 358);
191
+ assert.isBelow(thumbnailItem.height, 361);
182
192
 
183
- it('shares the specified image to the specified conversation', () => webex.internal.conversation.share(conversation, [sampleImageLargeJpg])
184
- .then((activity) => {
185
- assert.isActivity(activity);
186
- assert.isEncryptedActivity(activity);
193
+ return webex.internal.conversation.download(activity.object.files.items[0]);
194
+ })
195
+ .then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
196
+ .then((f) =>
197
+ fh.isMatchingFile(f, sampleImageLargeNoEXIFJpg).then((result) => assert.isTrue(result))
198
+ ));
199
+
200
+ it('shares the specified image to the specified conversation', () =>
201
+ webex.internal.conversation
202
+ .share(conversation, [sampleImageLargeJpg])
203
+ .then((activity) => {
204
+ assert.isActivity(activity);
205
+ assert.isEncryptedActivity(activity);
187
206
 
188
- const fileItem = activity.object.files.items[0];
207
+ const fileItem = activity.object.files.items[0];
189
208
 
190
- assert.isFileItem(fileItem);
209
+ assert.isFileItem(fileItem);
191
210
 
192
- const thumbnailItem = activity.object.files.items[0].image;
211
+ const thumbnailItem = activity.object.files.items[0].image;
193
212
 
194
- assert.isThumbnailItem(thumbnailItem);
195
- assert.equal(thumbnailItem.width, 640);
196
- assert.isAbove(thumbnailItem.height, 330);
197
- assert.isBelow(thumbnailItem.height, 361);
213
+ assert.isThumbnailItem(thumbnailItem);
214
+ assert.equal(thumbnailItem.width, 640);
215
+ assert.isAbove(thumbnailItem.height, 330);
216
+ assert.isBelow(thumbnailItem.height, 361);
198
217
 
199
- return webex.internal.conversation.download(activity.object.files.items[0]);
200
- })
201
- .then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
202
- .then((f) => fh.isMatchingFile(f, sampleImageLargeJpg)
203
- .then((result) => assert.isTrue(result))));
204
-
205
- it('shares the specified set of images the specified conversation', () => webex.internal.conversation.share(conversation, [sampleImageSmallOnePng, sampleImageSmallTwoPng])
206
- .then((activity) => {
207
- assert.isActivity(activity);
208
- assert.isEncryptedActivity(activity);
209
- assert.isFileItem(activity.object.files.items[0]);
210
- assert.isFileItem(activity.object.files.items[1]);
211
- assert.isThumbnailItem(activity.object.files.items[0].image);
212
- assert.isThumbnailItem(activity.object.files.items[1].image);
213
-
214
- return Promise.all([
215
- webex.internal.conversation.download(activity.object.files.items[0])
216
- .then(returnFirstArg((f) => assert.equal(f.type, 'image/png'))),
217
- webex.internal.conversation.download(activity.object.files.items[1])
218
- .then(returnFirstArg((f) => assert.equal(f.type, 'image/png')))
219
- ]);
220
- })
221
- .then(([file0, file1]) => Promise.all([
222
- fh.isMatchingFile(file0, sampleImageSmallOnePng)
223
- .then((result) => assert.isTrue(result)),
224
- fh.isMatchingFile(file1, sampleImageSmallTwoPng)
225
- .then((result) => assert.isTrue(result))
226
- ])));
218
+ return webex.internal.conversation.download(activity.object.files.items[0]);
219
+ })
220
+ .then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
221
+ .then((f) =>
222
+ fh.isMatchingFile(f, sampleImageLargeJpg).then((result) => assert.isTrue(result))
223
+ ));
224
+
225
+ it('shares the specified set of images the specified conversation', () =>
226
+ webex.internal.conversation
227
+ .share(conversation, [sampleImageSmallOnePng, sampleImageSmallTwoPng])
228
+ .then((activity) => {
229
+ assert.isActivity(activity);
230
+ assert.isEncryptedActivity(activity);
231
+ assert.isFileItem(activity.object.files.items[0]);
232
+ assert.isFileItem(activity.object.files.items[1]);
233
+ assert.isThumbnailItem(activity.object.files.items[0].image);
234
+ assert.isThumbnailItem(activity.object.files.items[1].image);
235
+
236
+ return Promise.all([
237
+ webex.internal.conversation
238
+ .download(activity.object.files.items[0])
239
+ .then(returnFirstArg((f) => assert.equal(f.type, 'image/png'))),
240
+ webex.internal.conversation
241
+ .download(activity.object.files.items[1])
242
+ .then(returnFirstArg((f) => assert.equal(f.type, 'image/png'))),
243
+ ]);
244
+ })
245
+ .then(([file0, file1]) =>
246
+ Promise.all([
247
+ fh
248
+ .isMatchingFile(file0, sampleImageSmallOnePng)
249
+ .then((result) => assert.isTrue(result)),
250
+ fh
251
+ .isMatchingFile(file1, sampleImageSmallTwoPng)
252
+ .then((result) => assert.isTrue(result)),
253
+ ])
254
+ ));
227
255
 
228
256
  describe('when it shares a transcodable file', () => {
229
257
  let activities;
@@ -238,7 +266,9 @@ describe('plugin-conversation', function () {
238
266
  blockUntilTranscode = new Defer();
239
267
  });
240
268
 
241
- afterEach(() => webex && webex.internal.mercury.off('event:conversation.activity', onMessage));
269
+ afterEach(
270
+ () => webex && webex.internal.mercury.off('event:conversation.activity', onMessage)
271
+ );
242
272
 
243
273
  function onMessage(message) {
244
274
  activities.push(message.data.activity);
@@ -248,7 +278,10 @@ describe('plugin-conversation', function () {
248
278
  }
249
279
 
250
280
  if (objectUrl) {
251
- const updateActivity = find(activities, (activity) => activity.verb === 'update' && activity.object.url === objectUrl);
281
+ const updateActivity = find(
282
+ activities,
283
+ (activity) => activity.verb === 'update' && activity.object.url === objectUrl
284
+ );
252
285
 
253
286
  if (updateActivity) {
254
287
  blockUntilTranscode.resolve(updateActivity);
@@ -258,43 +291,54 @@ describe('plugin-conversation', function () {
258
291
 
259
292
  // doesn't seem like we get mercury event back to update transcoded file in time
260
293
  // https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-166178
261
- it.skip('mercury receives an update', () => webex.internal.conversation.share(conversation, {
262
- object: {
263
- files: [samplePowerpointTwoPagePpt]
264
- },
265
- clientTempId
266
- })
267
- .then((activity) => {
268
- assert.equal(activity.clientTempId, clientTempId);
269
- activities.push(activity);
270
-
271
- return webex.internal.conversation.download(activity.object.files.items[0])
272
- .then((f) => assert.equal(f.type, 'application/vnd.ms-powerpoint'))
273
- .then(() => blockUntilTranscode.promise)
274
- .then((updateActivity) => {
275
- assert.equal(updateActivity.object.url, activity.object.url);
276
- assert.lengthOf(updateActivity.object.files.items[0].transcodedCollection.items[0].files.items, 2);
277
- // Prove that the newly transcoded file can be downloaded and
278
- // decrypted
279
- const firstItem = updateActivity.object.files.items[0].transcodedCollection.items[0].files.items[0];
280
-
281
- return webex.internal.conversation.download(firstItem);
282
- });
283
- }));
294
+ it.skip('mercury receives an update', () =>
295
+ webex.internal.conversation
296
+ .share(conversation, {
297
+ object: {
298
+ files: [samplePowerpointTwoPagePpt],
299
+ },
300
+ clientTempId,
301
+ })
302
+ .then((activity) => {
303
+ assert.equal(activity.clientTempId, clientTempId);
304
+ activities.push(activity);
305
+
306
+ return webex.internal.conversation
307
+ .download(activity.object.files.items[0])
308
+ .then((f) => assert.equal(f.type, 'application/vnd.ms-powerpoint'))
309
+ .then(() => blockUntilTranscode.promise)
310
+ .then((updateActivity) => {
311
+ assert.equal(updateActivity.object.url, activity.object.url);
312
+ assert.lengthOf(
313
+ updateActivity.object.files.items[0].transcodedCollection.items[0].files.items,
314
+ 2
315
+ );
316
+ // Prove that the newly transcoded file can be downloaded and
317
+ // decrypted
318
+ const firstItem =
319
+ updateActivity.object.files.items[0].transcodedCollection.items[0].files
320
+ .items[0];
321
+
322
+ return webex.internal.conversation.download(firstItem);
323
+ });
324
+ }));
284
325
  });
285
326
 
286
327
  it('shares a whiteboard', () => {
287
328
  const activity = webex.internal.conversation.makeShare(conversation);
288
329
 
289
330
  activity.add(sampleImageSmallOnePng, {
290
- actions: [{
291
- type: 'edit',
292
- mimeType: 'application/x-cisco-webex-whiteboard',
293
- url: 'https://boards.example.com/boards/1'
294
- }]
331
+ actions: [
332
+ {
333
+ type: 'edit',
334
+ mimeType: 'application/x-cisco-webex-whiteboard',
335
+ url: 'https://boards.example.com/boards/1',
336
+ },
337
+ ],
295
338
  });
296
339
 
297
- return webex.internal.conversation.share(conversation, activity)
340
+ return webex.internal.conversation
341
+ .share(conversation, activity)
298
342
  .then((share) => {
299
343
  assert.isActivity(share);
300
344
  assert.isEncryptedActivity(share);
@@ -303,40 +347,53 @@ describe('plugin-conversation', function () {
303
347
  assert.equal(share.object.contentCategory, 'documents');
304
348
  assert.isArray(share.object.files.items[0].actions);
305
349
  assert.equal(share.object.files.items[0].actions[0].type, 'edit');
306
- assert.equal(share.object.files.items[0].actions[0].mimeType, 'application/x-cisco-webex-whiteboard');
307
- assert.equal(share.object.files.items[0].actions[0].url, 'https://boards.example.com/boards/1');
308
-
309
- return webex.internal.conversation.download(share.object.files.items[0])
350
+ assert.equal(
351
+ share.object.files.items[0].actions[0].mimeType,
352
+ 'application/x-cisco-webex-whiteboard'
353
+ );
354
+ assert.equal(
355
+ share.object.files.items[0].actions[0].url,
356
+ 'https://boards.example.com/boards/1'
357
+ );
358
+
359
+ return webex.internal.conversation
360
+ .download(share.object.files.items[0])
310
361
  .then(returnFirstArg((f) => assert.equal(f.type, 'image/png')));
311
362
  })
312
- .then((file0) => fh.isMatchingFile(file0, sampleImageSmallOnePng)
313
- .then((result) => assert.isTrue(result)));
363
+ .then((file0) =>
364
+ fh.isMatchingFile(file0, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
365
+ );
314
366
  });
315
367
  });
316
368
 
317
369
  describe('#makeShare', () => {
318
370
  // http-core doesn't current do upload progress events in node, so this
319
371
  // test is browser-only for now
320
- skipInNode(flaky(it, process.env.SKIP_FLAKY_TESTS))('provides an interface for file upload events', () => {
321
- const spy = sinon.spy();
322
- const share = webex.internal.conversation.makeShare(conversation);
323
- const emitter = share.add(sampleImageSmallOnePng);
324
-
325
- emitter.on('progress', spy);
326
-
327
- return webex.internal.conversation.share(conversation, share)
328
- .then(() => assert.called(spy));
329
- });
372
+ skipInNode(flaky(it, process.env.SKIP_FLAKY_TESTS))(
373
+ 'provides an interface for file upload events',
374
+ () => {
375
+ const spy = sinon.spy();
376
+ const share = webex.internal.conversation.makeShare(conversation);
377
+ const emitter = share.add(sampleImageSmallOnePng);
378
+
379
+ emitter.on('progress', spy);
380
+
381
+ return webex.internal.conversation
382
+ .share(conversation, share)
383
+ .then(() => assert.called(spy));
384
+ }
385
+ );
330
386
 
331
387
  it('shares a file with a name', () => {
332
388
  const share = webex.internal.conversation.makeShare(conversation);
333
389
 
334
390
  share.add(sampleImageSmallOnePng);
335
391
  share.object = {
336
- displayName: 'a name'
392
+ displayName: 'a name',
337
393
  };
338
394
 
339
- return webex.internal.conversation.share(conversation, share)
395
+ return webex.internal.conversation
396
+ .share(conversation, share)
340
397
  .then((activity) => {
341
398
  assert.equal(activity.object.displayName, 'a name');
342
399
 
@@ -353,10 +410,11 @@ describe('plugin-conversation', function () {
353
410
  share.add(sampleImageSmallTwoPng);
354
411
  share.remove(sampleImageSmallOnePng);
355
412
  share.object = {
356
- displayName: 'a name'
413
+ displayName: 'a name',
357
414
  };
358
415
 
359
- return webex.internal.conversation.share(conversation, share)
416
+ return webex.internal.conversation
417
+ .share(conversation, share)
360
418
  .then((activity) => {
361
419
  assert.equal(activity.object.displayName, 'a name');
362
420
  assert.lengthOf(activity.object.files.items, 1);
@@ -372,19 +430,20 @@ describe('plugin-conversation', function () {
372
430
 
373
431
  share.add(sampleImageSmallOnePng);
374
432
  share.object = {
375
- displayName: 'a name'
433
+ displayName: 'a name',
376
434
  };
377
435
 
378
436
  let parentActivityId;
379
437
 
380
- return webex.internal.conversation.share(conversation, share)
438
+ return webex.internal.conversation
439
+ .share(conversation, share)
381
440
  .then((activity) => {
382
441
  assert.equal(activity.object.displayName, 'a name');
383
442
  const threadShare = webex.internal.conversation.makeShare(conversation);
384
443
 
385
444
  threadShare.add(sampleImageSmallOnePng);
386
445
  threadShare.object = {
387
- displayName: 'a thread share name'
446
+ displayName: 'a thread share name',
388
447
  };
389
448
  threadShare.activityType = 'reply';
390
449
  threadShare.parentActivityId = activity.id;
@@ -409,8 +468,8 @@ describe('plugin-conversation', function () {
409
468
  let blob, buffer;
410
469
 
411
470
  // Read file as buffer
412
- browserOnly(before)(() => fh.fetch(sampleGif)
413
- .then((file) => {
471
+ browserOnly(before)(() =>
472
+ fh.fetch(sampleGif).then((file) => {
414
473
  blob = file;
415
474
 
416
475
  return new Promise((resolve) => {
@@ -423,52 +482,56 @@ describe('plugin-conversation', function () {
423
482
  };
424
483
  fileReader.readAsArrayBuffer(blob);
425
484
  });
426
- }));
427
-
428
- browserOnly(it)('if the giphy does not exist, then we check it gets added to this.uploads', (done) => {
429
- // eslint-disable-next-line no-undef
430
- const file = new File([buffer], blob.name, {type: 'image/gif'});
431
-
432
- const originalGiphyURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy.gif';
433
- const originalGiphyStillURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy_s.gif';
434
- const url = 'https://giphy.com';
435
-
436
- // simulate in web client where
437
- Object.defineProperty(file, 'url', {value: originalGiphyURL});
438
- // define thumbnail
439
- Object.defineProperty(file, 'image', {
440
- value: {
441
- height: file.width,
442
- width: file.height,
443
- url: originalGiphyStillURL
444
- }
445
- });
446
-
447
- const share = webex.internal.conversation.makeShare(conversation);
485
+ })
486
+ );
487
+
488
+ browserOnly(it)(
489
+ 'if the giphy does not exist, then we check it gets added to this.uploads',
490
+ (done) => {
491
+ // eslint-disable-next-line no-undef
492
+ const file = new File([buffer], blob.name, {type: 'image/gif'});
493
+
494
+ const originalGiphyURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy.gif';
495
+ const originalGiphyStillURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy_s.gif';
496
+ const url = 'https://giphy.com';
497
+
498
+ // simulate in web client where
499
+ Object.defineProperty(file, 'url', {value: originalGiphyURL});
500
+ // define thumbnail
501
+ Object.defineProperty(file, 'image', {
502
+ value: {
503
+ height: file.width,
504
+ width: file.height,
505
+ url: originalGiphyStillURL,
506
+ },
507
+ });
448
508
 
449
- // Check that initially there were no uploads
450
- assert.isTrue(share.uploads.size === 0);
451
- share.addGif(file).then(() => {
452
- assert.equal(share.uploads.size, 1);
453
- assert.equal(share.uploads.get(file).objectType, 'file');
454
- assert.equal(share.uploads.get(file).displayName, sampleGif);
455
- assert.equal(share.uploads.get(file).mimeType, 'image/gif');
456
- assert.equal(share.uploads.get(file).fileSize, 473119);
457
- assert.equal(share.uploads.get(file).width, 200);
458
- assert.equal(share.uploads.get(file).height, 270);
459
- assert.equal(share.uploads.get(file).url, url);
460
- assert.exists(share.uploads.get(file).scr);
461
- assert.equal(share.uploads.get(file).scr.loc, originalGiphyURL);
462
-
463
- assert.exists(share.uploads.get(file).image);
464
- assert.equal(share.uploads.get(file).image.width, 200);
465
- assert.equal(share.uploads.get(file).image.height, 270);
466
- assert.equal(share.uploads.get(file).image.url, url);
467
- assert.exists(share.uploads.get(file).image.scr);
468
- assert.equal(share.uploads.get(file).image.scr.loc, originalGiphyStillURL);
469
- });
470
- done();
471
- });
509
+ const share = webex.internal.conversation.makeShare(conversation);
510
+
511
+ // Check that initially there were no uploads
512
+ assert.isTrue(share.uploads.size === 0);
513
+ share.addGif(file).then(() => {
514
+ assert.equal(share.uploads.size, 1);
515
+ assert.equal(share.uploads.get(file).objectType, 'file');
516
+ assert.equal(share.uploads.get(file).displayName, sampleGif);
517
+ assert.equal(share.uploads.get(file).mimeType, 'image/gif');
518
+ assert.equal(share.uploads.get(file).fileSize, 473119);
519
+ assert.equal(share.uploads.get(file).width, 200);
520
+ assert.equal(share.uploads.get(file).height, 270);
521
+ assert.equal(share.uploads.get(file).url, url);
522
+ assert.exists(share.uploads.get(file).scr);
523
+ assert.equal(share.uploads.get(file).scr.loc, originalGiphyURL);
524
+
525
+ assert.exists(share.uploads.get(file).image);
526
+ assert.equal(share.uploads.get(file).image.width, 200);
527
+ assert.equal(share.uploads.get(file).image.height, 270);
528
+ assert.equal(share.uploads.get(file).image.url, url);
529
+ assert.exists(share.uploads.get(file).image.scr);
530
+ assert.equal(share.uploads.get(file).image.scr.loc, originalGiphyStillURL);
531
+ });
532
+ done();
533
+ }
534
+ );
472
535
  });
473
536
  });
474
537
  });