@@ -2,16 +2,10 @@ import { expect, test } from "@jest/globals";
2
2
import { mocked } from "jest-mock" ;
3
3
4
4
import { SafeFilesCollection_ } from "../../../../src/backend/utils/SafeDriveService/SafeFilesCollection" ;
5
- import {
6
- mockedDrive ,
7
- mockedFilesCollection ,
8
- } from "../../../test-utils/gas-stubs" ;
5
+ import { mockedDrive } from "../../../test-utils/gas-stubs" ;
9
6
10
7
test ( "SafeFilesCollection constructs correctly" , ( ) => {
11
- global . Drive = {
12
- ...mockedDrive ( ) ,
13
- Files : mockedFilesCollection ( ) ,
14
- } ;
8
+ global . Drive = mockedDrive ( ) ;
15
9
16
10
expect ( ( ) => {
17
11
new SafeFilesCollection_ ( ) ;
@@ -29,7 +23,7 @@ test("copy works", () => {
29
23
name : "FILE_TITLE" ,
30
24
} ;
31
25
32
- global . Drive . Files = mockedFilesCollection ( ) ;
26
+ global . Drive = mockedDrive ( ) ;
33
27
const copy = mocked ( global . Drive . Files ) . copy . mockReturnValueOnce ( file ) ;
34
28
35
29
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -53,7 +47,7 @@ test("copy works with optional arguments", () => {
53
47
name : "FILE_TITLE" ,
54
48
} ;
55
49
56
- global . Drive . Files = mockedFilesCollection ( ) ;
50
+ global . Drive = mockedDrive ( ) ;
57
51
const copy = mocked ( global . Drive . Files ) . copy . mockReturnValueOnce ( file ) ;
58
52
59
53
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -76,7 +70,7 @@ test("copy works with selective fields", () => {
76
70
mimeType : "text/plain" ,
77
71
} ;
78
72
79
- global . Drive . Files = mockedFilesCollection ( ) ;
73
+ global . Drive = mockedDrive ( ) ;
80
74
const copy = mocked ( global . Drive . Files ) . copy . mockReturnValueOnce ( file ) ;
81
75
82
76
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -109,7 +103,7 @@ test("copy throws and error on invalid file", () => {
109
103
name : "FILE_TITLE" ,
110
104
} ;
111
105
112
- global . Drive . Files = mockedFilesCollection ( ) ;
106
+ global . Drive = mockedDrive ( ) ;
113
107
const copy = mocked ( global . Drive . Files ) . copy . mockReturnValueOnce ( file ) ;
114
108
115
109
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -133,7 +127,7 @@ test("get works", () => {
133
127
name : "FILE_TITLE" ,
134
128
} ;
135
129
136
- global . Drive . Files = mockedFilesCollection ( ) ;
130
+ global . Drive = mockedDrive ( ) ;
137
131
const get = mocked ( global . Drive . Files ) . get . mockReturnValueOnce ( file ) ;
138
132
139
133
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -156,7 +150,7 @@ test("get works with optional arguments", () => {
156
150
name : "FILE_TITLE" ,
157
151
} ;
158
152
159
- global . Drive . Files = mockedFilesCollection ( ) ;
153
+ global . Drive = mockedDrive ( ) ;
160
154
const get = mocked ( global . Drive . Files ) . get . mockReturnValueOnce ( file ) ;
161
155
162
156
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -174,7 +168,7 @@ test("get works with selective fields", () => {
174
168
name : "FILE_TITLE" ,
175
169
} ;
176
170
177
- global . Drive . Files = mockedFilesCollection ( ) ;
171
+ global . Drive = mockedDrive ( ) ;
178
172
const get = mocked ( global . Drive . Files ) . get . mockReturnValueOnce ( file ) ;
179
173
180
174
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -196,7 +190,7 @@ test("get throws an error on invalid file", () => {
196
190
name : "FILE_TITLE" ,
197
191
} ;
198
192
199
- global . Drive . Files = mockedFilesCollection ( ) ;
193
+ global . Drive = mockedDrive ( ) ;
200
194
const get = mocked ( global . Drive . Files ) . get . mockReturnValueOnce ( file ) ;
201
195
202
196
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -219,7 +213,7 @@ test("create works", () => {
219
213
name : "FILE_TITLE" ,
220
214
} ;
221
215
222
- global . Drive . Files = mockedFilesCollection ( ) ;
216
+ global . Drive = mockedDrive ( ) ;
223
217
const create = mocked ( global . Drive . Files ) . create . mockReturnValueOnce ( file ) ;
224
218
225
219
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -243,7 +237,7 @@ test("create works with optional arguments", () => {
243
237
name : "FILE_TITLE" ,
244
238
} ;
245
239
246
- global . Drive . Files = mockedFilesCollection ( ) ;
240
+ global . Drive = mockedDrive ( ) ;
247
241
const create = mocked ( global . Drive . Files ) . create . mockReturnValueOnce ( file ) ;
248
242
249
243
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -266,7 +260,7 @@ test("create works with selective fields", () => {
266
260
name : "FILE_TITLE" ,
267
261
} ;
268
262
269
- global . Drive . Files = mockedFilesCollection ( ) ;
263
+ global . Drive = mockedDrive ( ) ;
270
264
const create = mocked ( global . Drive . Files ) . create . mockReturnValueOnce ( file ) ;
271
265
272
266
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -296,7 +290,7 @@ test("create throws an error on invalid file", () => {
296
290
name : "FILE_TITLE" ,
297
291
} ;
298
292
299
- global . Drive . Files = mockedFilesCollection ( ) ;
293
+ global . Drive = mockedDrive ( ) ;
300
294
const create = mocked ( global . Drive . Files ) . create . mockReturnValueOnce ( file ) ;
301
295
302
296
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -333,7 +327,7 @@ test("list works", () => {
333
327
] ,
334
328
} ;
335
329
336
- global . Drive . Files = mockedFilesCollection ( ) ;
330
+ global . Drive = mockedDrive ( ) ;
337
331
const list = mocked ( global . Drive . Files ) . list . mockReturnValueOnce ( fileList ) ;
338
332
339
333
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -368,7 +362,7 @@ test("list works with optional arguments", () => {
368
362
] ,
369
363
} ;
370
364
371
- global . Drive . Files = mockedFilesCollection ( ) ;
365
+ global . Drive = mockedDrive ( ) ;
372
366
const list = mocked ( global . Drive . Files ) . list . mockReturnValueOnce ( fileList ) ;
373
367
374
368
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -405,7 +399,7 @@ test("list works with selective fields", () => {
405
399
] ,
406
400
} ;
407
401
408
- global . Drive . Files = mockedFilesCollection ( ) ;
402
+ global . Drive = mockedDrive ( ) ;
409
403
const list = mocked ( global . Drive . Files ) . list . mockReturnValueOnce ( fileList ) ;
410
404
411
405
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -444,7 +438,7 @@ test("list throws an error on invalid file", () => {
444
438
] ,
445
439
} ;
446
440
447
- global . Drive . Files = mockedFilesCollection ( ) ;
441
+ global . Drive = mockedDrive ( ) ;
448
442
const list = mocked ( global . Drive . Files ) . list . mockReturnValueOnce ( fileList ) ;
449
443
450
444
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -458,7 +452,7 @@ test("list throws an error on invalid file", () => {
458
452
test ( "list throws an error on invalid file list" , ( ) => {
459
453
const fileList = { } ;
460
454
461
- global . Drive . Files = mockedFilesCollection ( ) ;
455
+ global . Drive = mockedDrive ( ) ;
462
456
const list = mocked ( global . Drive . Files ) . list . mockReturnValueOnce ( fileList ) ;
463
457
464
458
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -470,7 +464,7 @@ test("list throws an error on invalid file list", () => {
470
464
} ) ;
471
465
472
466
test ( "remove works" , ( ) => {
473
- global . Drive . Files = mockedFilesCollection ( ) ;
467
+ global . Drive = mockedDrive ( ) ;
474
468
const remove = mocked ( global . Drive . Files ) . remove . mockImplementationOnce (
475
469
// eslint-disable-next-line @typescript-eslint/no-empty-function -- Implementation needed so the function is bound to local this
476
470
( ) => { } ,
@@ -495,7 +489,7 @@ test("update works", () => {
495
489
name : "FILE_TITLE" ,
496
490
} ;
497
491
498
- global . Drive . Files = mockedFilesCollection ( ) ;
492
+ global . Drive = mockedDrive ( ) ;
499
493
const update = mocked ( global . Drive . Files ) . update . mockReturnValueOnce ( file ) ;
500
494
501
495
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -520,7 +514,7 @@ test("update works with optional arguments", () => {
520
514
name : "FILE_TITLE" ,
521
515
} ;
522
516
523
- global . Drive . Files = mockedFilesCollection ( ) ;
517
+ global . Drive = mockedDrive ( ) ;
524
518
const update = mocked ( global . Drive . Files ) . update . mockReturnValueOnce ( file ) ;
525
519
526
520
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -549,7 +543,7 @@ test("update works with selective fields", () => {
549
543
} ,
550
544
} ;
551
545
552
- global . Drive . Files = mockedFilesCollection ( ) ;
546
+ global . Drive = mockedDrive ( ) ;
553
547
const update = mocked ( global . Drive . Files ) . update . mockReturnValueOnce ( file ) ;
554
548
555
549
const filesCollection = new SafeFilesCollection_ ( ) ;
@@ -574,7 +568,7 @@ test("update throws an error on invalid file", () => {
574
568
id : "FILE_ID" ,
575
569
} ;
576
570
577
- global . Drive . Files = mockedFilesCollection ( ) ;
571
+ global . Drive = mockedDrive ( ) ;
578
572
const update = mocked ( global . Drive . Files ) . update . mockReturnValueOnce ( file ) ;
579
573
580
574
const filesCollection = new SafeFilesCollection_ ( ) ;
0 commit comments