-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.js
745 lines (564 loc) · 21 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
// Import Tinytest from the tinytest Meteor package.
import { Tinytest } from 'meteor/tinytest';
import { Mongo } from 'meteor/mongo';
import { Random } from 'meteor/random';
import { Tracker } from 'meteor/tracker';
import { offlineCollections } from './lib/mongo';
import { Offline, clearAll, queueMethod } from 'meteor/jam:offline';
import { deepReplace, deepContains } from './lib/utils/shared';
const { getAll, canQueue, removeWithRetry } = Meteor.isClient && require('./lib/idb');
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
const applyOptions = {
returnStubValue: true,
...(Meteor.isFibersDisabled ? { returnServerResultPromise: true } : { isFromCallAsync: true })
}
Meteor.userId = () => '1'; // Mocked
const Things = new Mongo.Collection('things');
Things.keep({ text: 'stuff' }, { sort: { createdAt: 1 }, limit: 2 });
const Notes = new Mongo.Collection('notes');
Notes.keep({}, { limit: 2 });
const Dogs = new Mongo.Collection('dogs');
Dogs.keep({});
const Cars = new Mongo.Collection('cars');
Cars.keep({});
const Orders = new Mongo.Collection('orders', { idGeneration: 'MONGO' });
Orders.keep({});
const Items = new Mongo.Collection('items');
Items.keep({}, { sort: { updatedAt: 1 }, limit: 2 });
const Books = new Mongo.Collection('books');
Books.keep({ title: 'howdy' });
if (Meteor.isServer) {
Meteor.publish('things', function() {
return Things.find({});
});
Meteor.publish('notes', function() {
return Notes.find({});
});
Meteor.publish('dogs', function() {
return Dogs.find({});
});
Meteor.publish('cars', function() {
return Cars.find({});
});
Meteor.publish('orders', function() {
return Orders.find({});
});
Meteor.publish('items', function() {
return Items.find({});
});
Meteor.publish('books', function() {
return Books.find({});
});
}
const resetThings = async () => {
return Things.removeAsync({});
}
const resetNotes = async () => {
return Notes.removeAsync({});
}
const resetDogs = async () => {
return Dogs.removeAsync({});
}
const resetCars = async () => {
return Cars.removeAsync({});
}
const resetOrders = async () => {
return Orders.removeAsync({});
}
const resetItems = async () => {
return Items.removeAsync({});
}
const resetBooks = async () => {
return Books.removeAsync({});
}
const insertThing = async ({ text }) => {
return Things.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const updateThing = async ({ _id, text }) => {
return Things.updateAsync(_id, { $set: { text, createdAt: new Date(), updatedAt: new Date() }});
}
const insertNote = async ({ text }) => {
return Notes.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const updateNote = async ({ _id, text }) => {
return Notes.updateAsync(_id, { $set: { text, createdAt: new Date(), updatedAt: new Date() }});
}
const removeNote = async ({ _id, text }) => {
return Notes.removeAsync(_id);
}
const insertDog = async ({ text }) => {
return Dogs.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const upsertDog = async ({ _id, text }) => {
return Dogs.upsertAsync(_id, { text, createdAt: new Date(), updatedAt: new Date() });
}
const updateDog = async ({ _id, text }) => {
return Dogs.updateAsync(_id, { $set: { text, createdAt: new Date(), updatedAt: new Date() }});
}
const insertCar = async ({ text }) => {
return Cars.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const insertOrder = async ({ text }) => {
return Orders.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const updateOrder = async ({ _id, text }) => {
return Orders.updateAsync(_id, { $set: { text, createdAt: new Date(), updatedAt: new Date() }});
}
const removeOrder = async ({ _id, text }) => {
return Orders.removeAsync(_id);
}
const insertItem = async ({ text }) => {
return Items.insertAsync({ text, createdAt: new Date(), updatedAt: new Date() });
}
const updateItem = async ({ _id, text }) => {
return Items.updateAsync(_id, { $set: { text, createdAt: new Date(), updatedAt: new Date() }});
}
const insertBook = async ({ title }) => {
return Books.insertAsync({ title, createdAt: new Date(), updatedAt: new Date() });
}
const updateBook = async ({ _id, title }) => {
return Books.updateAsync(_id, { $set: { title, createdAt: new Date(), updatedAt: new Date() }});
}
Meteor.methods({ insertThing, updateThing, insertNote, updateNote, removeNote, insertDog, upsertDog, updateDog, insertCar, insertOrder, updateOrder, removeOrder, insertItem, updateItem, insertBook, updateBook });
if (Meteor.isServer) {
Meteor.methods({ resetThings, resetNotes, resetDogs, resetCars, resetOrders, resetItems, resetBooks })
}
// Client only tests
if (Meteor.isClient) {
Tinytest.addAsync('keep', async (test) => {
const things = offlineCollections.get('things')
test.equal(things.filter.text, 'stuff')
test.equal(things.sort.createdAt, 1)
test.equal(things.limit, 2)
});
Tinytest.addAsync('clear', async (test) => {
await Things.clear();
await Meteor.callAsync('resetThings');
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('things');
});
let things;
await Meteor.callAsync('insertThing', {text: 'stuff'});
await wait(100);
things = await getAll('things');
test.equal(things.length, 1);
await Things.clear();
things = await getAll('things');
test.equal(things.length, 0);
sub.stop();
comp.stop();
});
Tinytest.addAsync('clearAll', async (test) => {
await Meteor.callAsync('resetThings');
await Meteor.callAsync('resetNotes');
await clearAll();
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('things');
});
let sub2;
const comp2 = Tracker.autorun(() => {
sub2 = Meteor.subscribe('notes');
});
let things;
let notes;
await Meteor.callAsync('insertThing', {text: 'stuff'});
await Meteor.callAsync('insertNote', {text: 'hi'});
things = await getAll('things');
notes = await getAll('notes');
test.equal(things.length, 1);
test.equal(notes.length, 1);
await clearAll();
things = await getAll('things');
test.equal(things.length, 0);
notes = await getAll('notes');
test.equal(notes.length, 0);
sub.stop();
sub2.stop();
comp.stop();
comp2.stop();
});
Tinytest.addAsync('filter', async (test) => {
await wait(100)
await Meteor.callAsync('resetThings');
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('things');
});
await Meteor.callAsync('insertThing', {text: 'stuff'});
await wait(100);
await Meteor.callAsync('insertThing', {text: 'hi'});
await wait(100);
const things = await getAll('things');
test.equal(things.length, 1);
await Things.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('limit', async (test) => {
await wait(100);
await Meteor.callAsync('resetNotes');
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('notes');
});
await Meteor.callAsync('insertNote', {text: 'stuff'});
await wait(100);
await Meteor.callAsync('insertNote', {text: 'stuff'});
await wait(100);
await Meteor.callAsync('insertNote', {text: 'hi'});
await wait(100);
const notes = await getAll('notes');
test.equal(notes.length, 2);
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('sort - newest', async (test) => {
await Meteor.callAsync('resetNotes');
await Notes.clear();
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('notes');
});
const note1 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note2 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note3 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note4 = await Meteor.callAsync('insertNote', {text: 'hi'});
const notes = await getAll('notes');
test.equal(notes.length, 2);
test.isTrue(notes.map(t => t._id).includes(note3))
test.isTrue(notes.map(t => t._id).includes(note4))
test.isFalse(notes.map(t => t._id).includes(note1))
test.isFalse(notes.map(t => t._id).includes(note2))
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('sort - oldest', async (test) => {
await wait(100);
await Meteor.callAsync('resetItems');
await Items.clear();
await wait(100);
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('items');
});
const item1 = await Meteor.callAsync('insertItem', {text: 'stuff'});
await wait(100)
const item2 = await Meteor.callAsync('insertItem', {text: 'stuff'});
await wait(100)
const item3 = await Meteor.callAsync('insertItem', {text: 'stuff'});
await wait(100)
const item4 = await Meteor.callAsync('insertItem', {text: 'hi'});
await wait(100)
const items = await getAll('items');
test.equal(items.length, 2);
test.isTrue(items.map(t => t._id).includes(item1))
test.isTrue(items.map(t => t._id).includes(item2))
test.isFalse(items.map(t => t._id).includes(item3))
test.isFalse(items.map(t => t._id).includes(item4))
await Items.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('brief disconnect', async (test) => { // these tests can be a little flaky due to timing issues in simulating the methods and reconnecting etc.
await wait(200);
await Meteor.callAsync('resetNotes');
await Notes.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('notes');
});
const note1 = await Meteor.callAsync('insertNote', {text: 'hi'});
await wait(100)
const note2 = await Meteor.callAsync('insertNote', {text: 'hi'});
await wait(100);
Meteor.disconnect();
const note3 = await Meteor.applyAsync('insertNote', [{text: 'sup'}], { ...applyOptions, noRetry: true });
await queueMethod('insertNote', {text: 'sup'})
await wait(20);
Meteor.reconnect();
await wait(100);
const notes = await getAll('notes');
test.isFalse(notes.map(n => n._id).includes(note3));
test.isTrue(!notes.map(n => n._id).includes(note1));
test.equal(Notes.find().fetch().length, 3);
test.isTrue(Notes.find().fetch().map(n => n.text).includes('sup'));
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('browser refresh', async (test) => { // these tests can be a little flaky due to timing issues in simulating the methods and reconnecting etc.
await wait(200);
await Meteor.callAsync('resetNotes');
await Notes.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('notes');
});
const note1 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note2 = await Meteor.callAsync('insertNote', {text: 'hi'});
Meteor.disconnect();
const note3 = await Meteor.applyAsync('insertNote', [{text: 'sup'}], { ...applyOptions, noRetry: true });
await queueMethod('insertNote', {text: 'sup'})
// simulate page reload or user exits app and comes back later
Meteor.connection._methodInvokers = {};
await wait(100);
Meteor.reconnect();
await wait(50);
const notes = await getAll('notes');
test.isFalse(notes.map(n => n._id).includes(note3))
test.isTrue(!notes.map(n => n._id).includes(note1))
test.equal(Notes.find().fetch().length, 3)
test.isTrue(Notes.find().fetch().map(n => n.text).includes('sup'))
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('replay - add and change same doc', async (test) => {
await wait(200);
await Meteor.callAsync('resetNotes');
await Notes.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('notes');
});
const note1 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note2 = await Meteor.callAsync('insertNote', {text: 'sup'});
Meteor.disconnect();
await wait(100);
const note3 = await Meteor.applyAsync('insertNote', [{text: 'more'}], { ...applyOptions, noRetry: true });
await queueMethod('insertNote', {text: 'more'})
await wait(100);
await Meteor.applyAsync('updateNote', [{_id: note3, text: 'hello'}], { ...applyOptions, noRetry: true });
await queueMethod('updateNote', {_id: note3, text: 'hello'})
await wait(100);
Meteor.reconnect();
await wait(100);
const notes = await getAll('notes');
test.isFalse(notes.map(n => n._id).includes(note3)); // it should be swapped with the result of the queued method
test.isTrue(!notes.map(n => n._id).includes(note1));
test.equal(Notes.find().fetch().length, 3)
test.isTrue(Notes.find().fetch().map(n => n.text).includes('hello'))
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('replay - add and change same doc with upsert to preserve _id', async (test) => {
await wait(200);
await Meteor.callAsync('resetDogs');
await Dogs.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('dogs');
});
const dog1 = await Meteor.callAsync('insertDog', {text: 'hi'});
const dog2 = await Meteor.callAsync('insertDog', {text: 'sup'});
Meteor.disconnect();
await wait(100);
const dog3 = Random.id();
await Meteor.applyAsync('upsertDog', [{_id: dog3, text: 'more'}], { ...applyOptions, noRetry: true });
await queueMethod('upsertDog', {_id: dog3, text: 'more'})
await wait(200);
await Meteor.applyAsync('updateDog', [{_id: dog3, text: 'hello'}], { ...applyOptions, noRetry: true });
await queueMethod('updateDog', {_id: dog3, text: 'hello'});
await wait(100);
Meteor.reconnect();
await wait(10);
const dogs = await getAll('dogs');
test.isTrue(dogs.map(d => d._id).includes(dog3)) // it should be preserved
test.equal(Dogs.find().fetch().length, 3)
test.isTrue(Dogs.find().fetch().map(d => d.text).includes('hello'))
await Dogs.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('replay - add, change, remove', async (test) => {
await wait(200);
await Meteor.callAsync('resetNotes');
await Notes.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('notes');
});
const note1 = await Meteor.callAsync('insertNote', {text: 'hi'});
const note2 = await Meteor.callAsync('insertNote', {text: 'sup'});
const note3 = await Meteor.callAsync('insertNote', {text: 'to remove'});
Meteor.disconnect();
await wait(100);
const note4 = await Meteor.applyAsync('insertNote', [{text: 'another'}], { ...applyOptions, noRetry: true });
await queueMethod('insertNote', {text: 'another'})
await wait(200);
await Meteor.applyAsync('updateNote', [{_id: note1, text: 'hello'}], { ...applyOptions, noRetry: true });
await queueMethod('updateNote', {_id: note1, text: 'hello'})
await wait(200);
await Meteor.applyAsync('removeNote', [{_id: note3 }], { ...applyOptions, noRetry: true });
await queueMethod('removeNote', {_id: note3 })
await wait(100);
Meteor.reconnect();
await wait(100);
const notes = await getAll('notes');
test.isFalse(notes.map(n => n._id).includes(note4)) // it should be swapped with the result of the queued method
test.isTrue(notes.map(n => n._id).includes(note1))
test.isTrue(!notes.map(n => n._id).includes(note3))
test.equal(Notes.find().fetch().length, 3)
test.isTrue(Notes.find().fetch().map(n => n.text).includes('another'))
await Notes.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('replay - add, change, remove (Mongo.ObjectID)', async (test) => {
await wait(200);
await Meteor.callAsync('resetOrders');
await Orders.clear();
let sub;
const comp = Tracker.autorun(computation => {
sub = Meteor.subscribe('orders');
});
const order1 = await Meteor.callAsync('insertOrder', {text: 'hi'});
const order2 = await Meteor.callAsync('insertOrder', {text: 'hi'});
const order3 = await Meteor.callAsync('insertOrder', {text: 'to remove'});
Meteor.disconnect();
await wait(100);
const order4 = await Meteor.applyAsync('insertOrder', [{text: 'another'}], { ...applyOptions, noRetry: true });
await queueMethod('insertOrder', {text: 'another'})
await wait(200);
await Meteor.applyAsync('updateOrder', [{_id: order1, text: 'hello'}], { ...applyOptions, noRetry: true });
await queueMethod('updateOrder', {_id: order1, text: 'hello'})
await wait(200);
await Meteor.applyAsync('removeOrder', [{_id: order3 }], { ...applyOptions, noRetry: true });
await queueMethod('removeOrder', {_id: order3 })
await wait(100);
Meteor.reconnect();
await wait(100);
const orders = await getAll('orders');
test.isFalse(orders.map(o => o._id).includes(order4.toString())) // it should be swapped with the result of the queued method
test.isTrue(!orders.map(o=> o._id).includes(order1.toString()))
test.equal(Orders.find().fetch().length, 3)
test.isTrue(Orders.find().fetch().map(o => o.text).includes('another'))
await Orders.clear();
sub.stop();
comp.stop();
});
Tinytest.addAsync('methods are not queued when queueMethod is not used', async (test) => {
await wait(200);
await Cars.clear();
await Meteor.callAsync('resetCars');
let sub;
const comp = Tracker.autorun(() => {
sub = Meteor.subscribe('cars');
});
await wait(100);
Meteor.disconnect();
await wait(100);
await Meteor.applyAsync('insertCar', [{text: 'hi'}], { ...applyOptions, noRetry: true });
await wait(100);
const cars = await getAll('cars')
test.equal(cars.length, 1);
const methods = await getAll('methods');
test.equal(methods.length, 0);
await wait(100);
Meteor.reconnect();
await wait(100);
await Cars.clear();
sub.stop();
comp.stop();
});
Tinytest.add('canQueue', function (test) {
const originalConfig = Offline.config;
const originalOfflineCollections = offlineCollections;
// Test case 1: Offline.config.keepAll is true
Offline.configure({ keepAll: true });
test.isTrue(canQueue('insertTask'), 'Should queue method when keepAll is true');
// Test case 2: Offline.config.keepAll is false, matching collection name
Offline.configure({ keepAll: false });
offlineCollections.set('tasks', true);
test.isTrue(canQueue('insertTask'));
// Test case 3: Offline.config.keepAll is false, matching singular collection name
offlineCollections.clear(); // Clear previous collections
offlineCollections.set('tasks', true);
test.isTrue(canQueue('insertTasks'));
// Test case 4: Offline.config.keepAll is false, no matching collection name
offlineCollections.clear(); // Clear previous collections
test.isFalse(canQueue('updateUser'));
// return to previous setup
Offline.configure({...originalConfig});
for (const [key, value] of originalOfflineCollections) {
offlineCollections.set(key, value);
}
});
}
Tinytest.add('deepReplace', function (test) {
// Sample deeply nested object
const obj1 = {
$and: [
{ field1: { $gt: 5 } },
{ $or: [
{ field2: { $lt: 10 } },
{ field3: { $exists: true } }
]
}
]
};
// Perform deep replacement
const replacedObj1 = deepReplace(obj1, undefined, 'replacement');
// Expected result after replacement
const expectedObj1 = {
$and: [
{ field1: { $gt: 5 } },
{ $or: [
{ field2: { $lt: 10 } },
{ field3: { $exists: true } }
]
}
]
};
// Check if the objects are deeply equal
test.equal(replacedObj1, expectedObj1);
// Example with different replacement
const obj2 = {
$or: [
{ field1: { $eq: undefined } },
{ field2: { $ne: undefined } }
]
};
const replacedObj2 = deepReplace(obj2, undefined, 'new value');
const expectedObj2 = {
$or: [
{ field1: { $eq: 'new value' } },
{ field2: { $ne: 'new value' } }
]
};
test.equal(replacedObj2, expectedObj2);
// Example with non-nested object
const obj3 = {
key1: undefined,
key2: 10,
key3: undefined,
key4: 'some value'
};
const replacedObj3 = deepReplace(obj3, undefined, 'replacement');
const expectedObj3 = {
key1: 'replacement',
key2: 10,
key3: 'replacement',
key4: 'some value'
};
test.equal(replacedObj3, expectedObj3);
});
Tinytest.add('deepContains', function (test) {
const obj = { a: 1, b: { c: 2 } };
test.equal(deepContains(obj, 2), true);
test.equal(deepContains(obj, 3), false);
const str = 'hello';
test.equal(deepContains(str, 'hello'), true);
test.equal(deepContains(str, 'world'), false);
const arr = [1, 2, [3, 4]];
test.equal(deepContains(arr, 3), true);
test.equal(deepContains(arr, 5), false);
const deepArrOfObjs = [{ a: [{ b: { c: 3 } }] }, { d: { e: 4 } }];
test.equal(deepContains(deepArrOfObjs, 3), true);
test.equal(deepContains(deepArrOfObjs, 5), false);
});