-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.js
849 lines (720 loc) · 22 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
import { Tinytest } from 'meteor/tinytest';
import { Meteor } from 'meteor/meteor';
import {
wait,
schema,
run,
mockedMethod,
defaultAuthed,
checkSchema,
zodSchema,
simpleSchema,
customValidate,
customValidateAsync,
test1,
testAsync,
testAsyncErrorClient,
testAsyncErrorServer,
asyncMethod,
noRetryMethod,
voidMethod,
rateLimited,
errorMethod,
wait100,
fastMethod,
beforeMethod,
beforeArrayMethod,
afterMethod,
afterArrayMethod,
serverOnly,
configMethod,
simplePipeline,
voidPipeline,
asyncPipeline,
methodUnblock,
contextMethod,
getEvents,
contextFailedMethod,
addSelected,
addSelectedAsync,
rollBackAsync,
removeSelected,
Selected,
globalBefore,
globalAfter,
setOptions,
checkOwnership,
addSelectedAsyncWithOwner,
addSelectedAsyncWithOwnerPipe,
numMethod,
numMethod2,
editMethod,
editMethod2,
editMethod3,
editMethod4,
closedMethod,
closedMethod2,
closedMethod3,
openMethod,
openMethod2,
openMethod3,
schemalessMethod,
schemalessMethod2,
schemalessMethod3,
schemaedMethod,
schemaedMethod2,
schemaedMethod3,
Todos
} from './test-methods.js';
Tinytest.addAsync('methods - mock context', async(test) => {
const mockContext = {
userId: 'fakeUserId',
connection: { id: 'fakeConnectionId' }
};
const result = await mockedMethod.call(mockContext, { num: 5 });
test.equal(result.userId, 'fakeUserId');
test.equal(result.num, 5);
})
Meteor.userId = () => '1'; // Mocked
Tinytest.addAsync('methods - basic', async (test) => {
const result = await test1();
test.equal(result, 5);
});
Tinytest.addAsync('methods - basic async', async (test) => {
const result = await testAsync({num: 1});
test.equal(result, 10);
});
if (Meteor.isFibersDisabled && Meteor.isClient) { // 3.x
Tinytest.addAsync('methods - handle stub manually', async (test) => {
const { stubPromise, serverPromise } = testAsync({num: 1});
const stub = await stubPromise?.catch(error => {
test.equal('should never be reached', true);
});
test.equal(stub, 10);
const serverResult = await serverPromise?.catch(error => {
test.equal('should never be reached', true);
});
test.equal(serverResult, 10);
});
Tinytest.addAsync('methods - handle stub manually client error', async (test) => {
const { stubPromise, serverPromise } = testAsyncErrorClient({num: 1});
const stub = await stubPromise?.catch(error => {
test.equal(error.error, 'client error');
});
test.equal(stub, undefined);
const serverResult = await serverPromise?.catch(error => {
test.equal(error.error, 'client error');
});
test.equal(serverResult, undefined);
});
Tinytest.addAsync('methods - handle stub manually server error', async (test) => {
const { stubPromise, serverPromise } = testAsyncErrorServer({num: 1});
const stub = await stubPromise.catch(error => {
test.equal('should never be reached', true);
});
test.equal(stub, 10);
const serverResult = await serverPromise.catch(error => {
test.equal(error.error, 'server error');
});
test.equal(serverResult, undefined);
});
}
Tinytest.addAsync('methods - dependent', async (test) => {
const r = await testAsync({num: 1})
const result = await testAsync({num: r})
test.equal(result, 100)
})
Tinytest.addAsync('methods - authed by default', async (test) => {
try {
const result = await defaultAuthed();
test.equal('should never be reached', true);
} catch(e) {
test.equal(e.reason, 'You must be logged in')
}
});
Tinytest.addAsync('methods - check schema', async (test) => {
const result = await checkSchema({ num: 25, isPrivate: true });
test.equal(result, 50);
});
Tinytest.addAsync('methods - zod schema', async (test) => {
const result = await zodSchema({ num: 4, isPrivate: true });
test.equal(result, 40);
});
Tinytest.addAsync('methods - SimpleSchema', async (test) => {
const result = await simpleSchema({ num: 5, isPrivate: true });
test.equal(result, 100);
});
Tinytest.addAsync('methods - custom validate', async (test) => {
const result = await customValidate({ num: 20 });
test.equal(result, 20);
});
Tinytest.addAsync('methods - custom validate async', async (test) => {
const result = await customValidateAsync({ num: 20 });
test.equal(result, 20);
});
Tinytest.addAsync('methods - custom validate async fail', async (test) => {
try {
const result = await customValidateAsync({ num: 5 });
test.equal('should never be reached', true);
} catch (error) {
test.equal(error, 'fail')
}
});
Tinytest.addAsync('methods - void', async (test) => {
try {
const result = await voidMethod({ num: 20 });
test.equal(result, undefined)
} catch (error) {
test.equal('should never be reached', true);
}
});
Tinytest.addAsync('.validate - check schema', async (test) => {
try {
const result = checkSchema.validate({ num: 25, isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - check schema fail', async (test) => {
try {
const result = checkSchema.validate({ num: '25', isPrivate: true });
test.equal('should not be reached', true)
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - check .only schema', async (test) => {
try {
const result = checkSchema.validate.only({ isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - check .only schema fail', async (test) => {
try {
const result = checkSchema.validate.only({ isPrivate: 'true' });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - zod schema', async (test) => {
try {
const result = await zodSchema.validate({ num: 4, isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - zod schema fail', async (test) => {
try {
const result = await zodSchema.validate({ num: '4', isPrivate: true });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - zod schema .only', async (test) => {
try {
const result = await zodSchema.validate.only({ isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - zod schema .only fail', async (test) => {
try {
const result = await zodSchema.validate.only({ isPrivate: 'true' });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - SimpleSchema', async (test) => {
try {
const result = await simpleSchema.validate({ num: 5, isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - SimpleSchema fail', async (test) => {
try {
const result = await simpleSchema.validate({ num: '5', isPrivate: true });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - SimpleSchema .only', async (test) => {
try {
const result = await simpleSchema.validate.only({ isPrivate: true });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - SimpleSchema .only fail', async (test) => {
try {
const result = await simpleSchema.validate.only({ isPrivate: 'true' });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - custom validate', async (test) => {
try {
const result = await customValidate.validate({ num: 20 });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - custom validate fail', async (test) => {
try {
const result = await customValidate.validate({ num: '20' });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
Tinytest.addAsync('.validate - custom validate async', async (test) => {
try {
const result = await customValidateAsync.validate({ num: 20 });
} catch (error) {
test.equal('should not be reached', true)
}
});
Tinytest.addAsync('.validate - custom validate async fail', async (test) => {
try {
const result = await customValidateAsync.validate({ num: 20 });
} catch (error) {
test.isTrue(error instanceof Error)
}
});
if (Meteor.isClient) {
Tinytest.addAsync('methods - error', async (test) => {
try {
await errorMethod();
test.equal('should never be reached', true);
} catch (e) {
test.equal(e.message, 'test error');
}
});
}
Tinytest.addAsync('methods - unblock', async (test) => {
const result = await methodUnblock(5);
test.equal(result, 10);
});
if (Meteor.isClient) {
// for some reason this test will fail in 2.x when run with the other tests, but if it's run by itself it passes
// rateLimit also works when used so I think it must have something to do with Tinytest
Tinytest.addAsync('methods - rate limit', async (test) => {
for (let i = 0; i < 5; i++) {
await rateLimited();
}
try {
await rateLimited();
test.equal('should never be reached', true);
} catch (e) {
test.equal(e.error, 'too-many-requests');
}
});
}
/* if (Meteor.isClient) { // TODO: is there another way to test this without setTimeout which can't be used in 3.x methods?
Tinytest.addAsync('methods - async parallelize', async (test) => {
let order = [];
await Promise.all([
wait100().then(() => order.push('wait100'))),
fastMethod().then(() => order.push('fastMethod'))
]);
test.equal(order, ['fastMethod', 'wait100']);
});
} else {
Tinytest.addAsync('methods - async block by default', async (test) => {
let order = [];
await Promise.all([
wait100().then(() => order.push('wait100')),
fastMethod().then(() => order.push('fastMethod'))
]);
test.equal(order, ['wait100', 'fastMethod']);
});
} */
Tinytest.addAsync('methods - async sequential', async (test) => {
let order = [];
await wait100()
order.push('wait100')
await fastMethod()
order.push('fastMethod')
test.equal(order, ['wait100', 'fastMethod']);
});
Tinytest.addAsync('methods - beforeMethod', async (test) => {
const result = await beforeMethod({num: 10})
test.equal(result, 20);
});
Tinytest.addAsync('methods - beforeArrayMethod', async (test) => {
const result = await beforeArrayMethod({num: 20})
test.equal(result, 40);
});
Tinytest.addAsync('methods - afterMethod', async (test) => {
const result = await afterMethod({num: 10})
test.equal(result, 30);
});
Tinytest.addAsync('methods - afterArrayMethod', async (test) => {
const result = await afterArrayMethod({num: 20})
test.equal(result, 60);
});
Tinytest.addAsync('methods - serverOnly', async (test) => {
const result = serverOnly({num: 5})
if (Meteor.isClient) {
test.equal(await result.stubPromise, undefined);
} else {
test.equal(await result, 15);
}
});
Tinytest.addAsync('methods - pipeline', async (test) => {
const result = await simplePipeline(10)
test.equal(result, 14.5);
});
Tinytest.addAsync('methods - void pipeline', async (test) => {
const result = await voidPipeline(10)
test.equal(result, 14.5);
});
Tinytest.addAsync('methods - async pipeline', async (test) => {
const result = await asyncPipeline(10)
test.equal(result, 14.5);
});
Tinytest.addAsync('methods - context success', async (test) => {
const result = await contextMethod(5);
test.equal(result, true);
const events = await getEvents();
test.equal(events, ['result: true']);
});
Tinytest.addAsync('methods - context error', async (test) => {
try {
await contextFailedMethod(5);
test.equal('should never be reached', true);
} catch (e) {
test.equal(e.message, '[second err]');
}
const events = await getEvents();
test.equal(events, ['first err', 'first err']);
});
if (Meteor.isClient) {
Tinytest.addAsync('methods - insert', async (test) => {
const result = await addSelected({num: 1});
test.equal(result, '123');
});
Tinytest.addAsync('methods - insertAsync', async (test) => {
const result = await addSelectedAsync({num: 1});
test.equal(result, '2');
});
}
/*
// probably run independently, can screw up the other tests
Tinytest.addAsync('methods - global before', async (test) => {
const result = await globalBefore(5);
test.equal(result, 6);
});
/*
// must be run on its own otherwise it screws up other tests
Tinytest.addAsync('methods - global after', async (test) => {
const result = await globalAfter(5);
test.equal(result, 4);
}); */
if (Meteor.isClient) {
Tinytest.addAsync('methods - set returnStubValue false', async (test) => {
const result = await setOptions(5);
test.equal(result, undefined);
});
}
/* Tinytest.addAsync('methods - async .then', async (test) => { // TODO: is there another way to test this without setTimeout which can't be used in 3.x methods
const result = await asyncMethod({ num: 3000 }).then(result => {
test.equal(result, 'result,result2,3000');
});
}); */
if (Meteor.isClient) {
Tinytest.addAsync('methods - rollBack', async (test) => {
try {
const result = await rollBackAsync({num: 2});
} catch(e) {
test.equal(e.message, '[server error]')
const result = await Selected.findOneAsync({_id: '4'})
test.equal(result, undefined)
}
});
}
Tinytest.addAsync('methods - check ownership pipe', async (test) => {
try {
const result = await addSelectedAsyncWithOwnerPipe({num: 2, ownerId: '12'})
test.equal(result, '6')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('methods - check ownership run', async (test) => {
try {
const result = await addSelectedAsyncWithOwner({num: 4, ownerId: '20'})
test.equal(result, '12')
} catch(e) {
console.error(e)
}
});
if (Meteor.isClient) {
Tinytest.addAsync('attached methods - create', async (test) => {
try {
const result = await Todos.create({text: 'hi'})
test.isTrue(result)
} catch(e) {
console.error('create', e)
}
});
Tinytest.addAsync('attached methods - edit', async (test) => {
try {
const result = await Todos.edit({text: 'bye'})
test.equal(result, 'bye');
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('attached methods - num', async (test) => {
try {
const result = await Todos.num(5)
test.equal(result, 5);
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('attached methods - num fail', async (test) => {
try {
const result = await Todos.num('5')
} catch(e) {
console.error(e)
test.equal(e.details[0].message, 'Expected number, got string')
}
});
Tinytest.addAsync('attached methods - custom', async (test) => {
try {
const result = await Todos.custom({ _id: '1', num: 10 })
test.equal(result, {_id: '1', num: 10});
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('attached methods - custom fail', async (test) => {
try {
const result = await Todos.custom({ _id: '1', num: '10' })
} catch(e) {
console.error(e);
test.equal(e.details[0].message, 'Num must be a number, not string');
}
});
Tinytest.addAsync('attached methods - authRequired', async (test) => {
try {
const result = await Todos.authRequired({ text: 'hi' })
} catch(e) {
console.error(e)
test.isTrue(e)
}
});
Tinytest.addAsync('attached methods - openMethod', async (test) => {
try {
const result = await Todos.unAuthed({ text: 'hi' })
test.equal(result, 'hi');
} catch(e) {
console.error(e)
}
});
}
/* test fn.name manually via console log
Tinytest.addAsync('functional syntax - names', async (test) => {
await numMethod(1).catch(e => console.error(e)) // fn.name number-1
await numMethod2(2).catch(e => console.error(e)) // fn.name number-2
await editMethod({text: 'hi'}).catch(e => console.error(e)), // fn.name edit2
await editMethod2({text: 'hi'}).catch(e => console.error(e)), // fn.name text-4, serverOnly
await editMethod3({text: 'hi'}).catch(e => console.error(e)), // fn.name edit4, serverOnly
await editMethod4({text: 'hi'}).catch(e => console.error(e)), // fn.name text-6, serverOnly
await closedMethod({text: 'hi'}).catch(e => console.error(e)), // fn.name text-7
await closedMethod2({text: 'hi'}).catch(e => console.error(e)), // fn.name authRequired2, serverOnly
await closedMethod3({text: 'hi'}).catch(e => console.error(e)), // fn.name text-9, serverOnly
await openMethod({text: 'hi'}).catch(e => console.error(e)), // fn.name text-10
await openMethod2({text: 'hi'}).catch(e => console.error(e)), // fn.name text-11, serverOnly
await openMethod3({text: 'hi'}).catch(e => console.error(e)) // fn.name unAuthed2, serverOnly
});
*/
Tinytest.addAsync('functional syntax - numMethod', async (test) => {
try {
const result = await numMethod(1);
test.equal(result, 1)
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - numMethod2', async (test) => {
try {
const result = await numMethod2(2);
test.equal(result, 2)
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - editMethod', async (test) => {
try {
const result = await editMethod({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - editMethod2', async (test) => {
try {
const result = await editMethod2({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - editMethod3', async (test) => {
try {
const result = await editMethod3({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - editMethod4', async (test) => {
try {
const result = await editMethod4({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - closedMethod', async (test) => {
try {
const result = await closedMethod({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - closedMethod2', async (test) => {
try {
const result = await closedMethod2({text: 'hi'})
if (Meteor.isClient) {
test.equal(result, undefined)
} else {
test.equal(result, 'hi')
}
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - closedMethod3', async (test) => {
try {
const result = await closedMethod3({text: 'hi'})
if (Meteor.isClient) {
test.equal(result, undefined)
} else {
test.equal(result, 'hi')
}
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - openMethod', async (test) => {
try {
const result = await openMethod({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - openMethod2', async (test) => {
try {
const result = await openMethod2({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('functional syntax - openMethod3', async (test) => {
try {
const result = await openMethod3({text: 'hi'})
test.equal(result, 'hi')
} catch(e) {
console.error(e)
}
});
Tinytest.addAsync('schemaless - functional syntax', async (test) => {
const result = await schemalessMethod();
test.equal(result, 'hello')
});
Tinytest.addAsync('schemaless - regular syntax', async (test) => {
const result = await schemalessMethod2();
test.equal(result, 'hello')
});
Tinytest.addAsync('schemaless - pipe syntax', async (test) => {
const result = await schemalessMethod3();
test.equal(result, 'hello')
});
Tinytest.addAsync('schemaed - functional syntax', async (test) => {
try {
const result = await schemaedMethod();
} catch(e) {
test.equal(e.message, "You must pass in either a schema or a validate function for method 'schemaed'")
}
});
Tinytest.addAsync('schemaed - regular syntax', async (test) => {
try {
const result = await schemaedMethod2();
} catch(e) {
test.equal(e.message, "You must pass in either a schema or a validate function for method 'schemaedMethod2'")
}
});
Tinytest.addAsync('schemaed - pipe syntax', async (test) => {
try {
const result = await schemaedMethod3();
} catch(e) {
test.equal(e.message, "You must pass in either a schema or a validate function for method 'schemaedMethod3'")
}
});
if (Meteor.isClient) {
Tinytest.addAsync('jam:offline - Meteor.applyAsync is called with the expected options', async (test) => {
let applyOptions;
const originalApply = Meteor.applyAsync;
Meteor.applyAsync = async function (name, args, options, callback) {
applyOptions = options;
return originalApply.call(this, name, args, options, callback);
};
await wait(100);
testAsync({num: 1});
test.equal(applyOptions.noRetry, undefined);
await wait(100);
Meteor.disconnect();
await wait(100);
testAsync({num: 1});
await wait(100);
test.equal(applyOptions.noRetry, true);
await wait(100);
Meteor.reconnect();
await wait(100);
testAsync({num: 1});
await wait(100)
test.equal(applyOptions.noRetry, undefined);
Meteor.applyAsync = originalApply;
});
Tinytest.addAsync('jam:offline - Meteor.applyAsync noRetry is preserved when explicitly set', async (test) => {
let applyOptions;
const originalApply = Meteor.applyAsync;
Meteor.applyAsync = async function (name, args, options, callback) {
applyOptions = options;
return originalApply.call(this, name, args, options, callback);
};
await wait(100);
noRetryMethod({num: 1});
test.equal(applyOptions.noRetry, true);
await wait(100);
Meteor.disconnect();
await wait(100);
noRetryMethod({num: 1});
await wait(100);
test.equal(applyOptions.noRetry, true);
await wait(100);
Meteor.reconnect();
await wait(100);
noRetryMethod({num: 1});
await wait(100)
test.equal(applyOptions.noRetry, true);
Meteor.applyAsync = originalApply;
});
}