UNPKG

22.6 kBJavaScriptView Raw
1'use strict';
2
3module.exports = function (dbType, context) {
4
5 describe(dbType + ': issue66', function () {
6
7 beforeEach(function () {
8 return context.db.bulkDocs([
9 {
10 name: 'Mario',
11 _id: 'mario',
12 rank: 5,
13 series: 'Mario',
14 debut: 1981,
15 awesome: true
16 },
17 {
18 name: 'Jigglypuff',
19 _id: 'puff',
20 rank: 8,
21 series: 'Pokemon',
22 debut: 1996,
23 awesome: false
24 },
25 {
26 name: 'Link',
27 rank: 10,
28 _id: 'link',
29 series: 'Zelda',
30 debut: 1986,
31 awesome: true
32 },
33 {
34 name: 'Donkey Kong',
35 rank: 7,
36 _id: 'dk',
37 series: 'Mario',
38 debut: 1981,
39 awesome: false
40 },
41 {
42 name: 'Pikachu',
43 series: 'Pokemon',
44 _id: 'pikachu',
45 rank: 1,
46 debut: 1996,
47 awesome: true
48 },
49 {
50 name: 'Captain Falcon',
51 _id: 'falcon',
52 rank: 4,
53 series: 'F-Zero',
54 debut: 1990,
55 awesome: true
56 },
57 {
58 name: 'Luigi',
59 rank: 11,
60 _id: 'luigi',
61 series: 'Mario',
62 debut: 1983,
63 awesome: false
64 },
65 {
66 name: 'Fox',
67 _id: 'fox',
68 rank: 3,
69 series: 'Star Fox',
70 debut: 1993,
71 awesome: true
72 },
73 {
74 name: 'Ness',
75 rank: 9,
76 _id: 'ness',
77 series: 'Earthbound',
78 debut: 1994,
79 awesome: true
80 },
81 {
82 name: 'Samus',
83 rank: 12,
84 _id: 'samus',
85 series: 'Metroid',
86 debut: 1986,
87 awesome: true
88 },
89 {
90 name: 'Yoshi',
91 _id: 'yoshi',
92 rank: 6,
93 series: 'Mario',
94 debut: 1990,
95 awesome: true
96 },
97 {
98 name: 'Kirby',
99 _id: 'kirby',
100 series: 'Kirby',
101 rank: 2,
102 debut: 1992,
103 awesome: true
104 },
105 {
106 name: 'Master Hand',
107 _id: 'master_hand',
108 series: 'Smash Bros',
109 rank: 0,
110 debut: 1999,
111 awesome: false
112 }
113 ]);
114 });
115
116 it('should query all docs with $gt: null', function () {
117 var db = context.db;
118 return db.bulkDocs(
119 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
120 ).then(function () {
121 return db.find({
122 selector: {
123 _id: {$gt: null}
124 }
125 }).then(function (response) {
126 response.docs.map(function (doc) {
127 return doc._id;
128 }).sort().should.deep.equal(
129 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
130 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
131 'yoshi']
132 );
133 });
134 });
135 });
136
137 it('should query all docs with $lt: false', function () {
138 var db = context.db;
139 return db.bulkDocs(
140 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
141 ).then(function () {
142 return db.find({
143 selector: {
144 _id: {$lt: false}
145 }
146 }).then(function (response) {
147 response.docs.should.deep.equal([]);
148 });
149 });
150 });
151
152 it('should query all docs with $lt: {}', function () {
153 var db = context.db;
154 return db.bulkDocs(
155 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
156 ).then(function () {
157 return db.find({
158 selector: {
159 _id: {$lt: {}}
160 }
161 }).then(function (response) {
162 response.docs.should.deep.equal([]);
163 });
164 });
165 });
166
167 it('should query all docs with $lte: {}', function () {
168 var db = context.db;
169 return db.bulkDocs(
170 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
171 ).then(function () {
172 return db.find({
173 selector: {
174 _id: {$lte: {}}
175 }
176 }).then(function (response) {
177 response.docs.should.deep.equal([]);
178 });
179 });
180 });
181
182 it('should query all docs with $lte: []', function () {
183 var db = context.db;
184 return db.bulkDocs(
185 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
186 ).then(function () {
187 return db.find({
188 selector: {
189 _id: {$lte: []}
190 }
191 }).then(function (response) {
192 response.docs.should.deep.equal([]);
193 });
194 });
195 });
196
197 it('should query all docs with $lte: null', function () {
198 var db = context.db;
199 return db.bulkDocs(
200 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
201 ).then(function () {
202 return db.find({
203 selector: {
204 _id: {$lte: null}
205 }
206 }).then(function (response) {
207 response.docs.should.deep.equal([]);
208 });
209 });
210 });
211
212 it('should query all docs with $lt: null', function () {
213 var db = context.db;
214 return db.bulkDocs(
215 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
216 ).then(function () {
217 return db.find({
218 selector: {
219 _id: {$lt: null}
220 }
221 }).then(function (response) {
222 response.docs.should.deep.equal([]);
223 });
224 });
225 });
226
227 it('should query all docs with $gt: false', function () {
228 var db = context.db;
229 return db.bulkDocs(
230 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
231 ).then(function () {
232 return db.find({
233 selector: {
234 _id: {$gt: false}
235 }
236 }).then(function (response) {
237 response.docs.map(function (doc) {
238 return doc._id;
239 }).sort().should.deep.equal(
240 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
241 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
242 'yoshi']
243 );
244 });
245 });
246 });
247
248 it('should query all docs with $gte: 0', function () {
249 var db = context.db;
250 return db.bulkDocs(
251 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
252 ).then(function () {
253 return db.find({
254 selector: {
255 _id: {$gte: 0}
256 }
257 }).then(function (response) {
258 response.docs.map(function (doc) {
259 return doc._id;
260 }).sort().should.deep.equal(
261 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
262 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
263 'yoshi']
264 );
265 });
266 });
267 });
268
269 it('should query all docs with $gt: 0', function () {
270 var db = context.db;
271 return db.bulkDocs(
272 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
273 ).then(function () {
274 return db.find({
275 selector: {
276 _id: {$gt: 0}
277 }
278 }).then(function (response) {
279 response.docs.map(function (doc) {
280 return doc._id;
281 }).sort().should.deep.equal(
282 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
283 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
284 'yoshi']
285 );
286 });
287 });
288 });
289
290 it('should query all docs with $gte: false', function () {
291 var db = context.db;
292 return db.bulkDocs(
293 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
294 ).then(function () {
295 return db.find({
296 selector: {
297 _id: {$gte: false}
298 }
299 }).then(function (response) {
300 response.docs.map(function (doc) {
301 return doc._id;
302 }).sort().should.deep.equal(
303 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
304 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
305 'yoshi']
306 );
307 });
308 });
309 });
310
311 it('should query all docs with $gt: {}', function () {
312 var db = context.db;
313 return db.bulkDocs(
314 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
315 ).then(function () {
316 return db.find({
317 selector: {
318 _id: {$gt: {}}
319 }
320 }).then(function (response) {
321 response.docs.map(function (doc) {
322 return doc._id;
323 }).sort().should.deep.equal(
324 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
325 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
326 'yoshi']
327 );
328 });
329 });
330 });
331
332 it('should query all docs with $gte: {}', function () {
333 var db = context.db;
334 return db.bulkDocs(
335 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
336 ).then(function () {
337 return db.find({
338 selector: {
339 _id: {$gte: {}}
340 }
341 }).then(function (response) {
342 response.docs.map(function (doc) {
343 return doc._id;
344 }).sort().should.deep.equal(
345 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
346 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
347 'yoshi']
348 );
349 });
350 });
351 });
352
353 it('should query all docs with $eq: {}', function () {
354 var db = context.db;
355 return db.bulkDocs(
356 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
357 ).then(function () {
358 return db.find({
359 selector: {
360 _id: {$eq: {}}
361 }
362 }).then(function (response) {
363 response.docs.should.deep.equal([]);
364 });
365 });
366 });
367
368 it('should query all docs with $eq: null', function () {
369 var db = context.db;
370 return db.bulkDocs(
371 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
372 ).then(function () {
373 return db.find({
374 selector: {
375 _id: {$eq: null}
376 }
377 }).then(function (response) {
378 response.docs.should.deep.equal([]);
379 });
380 });
381 });
382
383 it('should query all docs with $eq: 0', function () {
384 var db = context.db;
385 return db.bulkDocs(
386 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
387 ).then(function () {
388 return db.find({
389 selector: {
390 _id: {$eq: 0}
391 }
392 }).then(function (response) {
393 response.docs.should.deep.equal([]);
394 });
395 });
396 });
397
398 it('should query all docs with $eq: null', function () {
399 var db = context.db;
400 return db.bulkDocs(
401 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
402 ).then(function () {
403 return db.find({
404 selector: {
405 _id: {$eq: null}
406 }
407 }).then(function (response) {
408 response.docs.should.deep.equal([]);
409 });
410 });
411 });
412
413 it('should query all docs with $lte: 0', function () {
414 var db = context.db;
415 return db.bulkDocs(
416 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
417 ).then(function () {
418 return db.find({
419 selector: {
420 _id: {$lte: 0}
421 }
422 }).then(function (response) {
423 response.docs = response.docs.map(function (doc) {
424 return doc._id;
425 });
426 response.docs.should.deep.equal([]);
427 });
428 });
429 });
430
431 it('should query all docs with $gte: null', function () {
432 var db = context.db;
433 return db.bulkDocs(
434 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
435 ).then(function () {
436 return db.find({
437 selector: {
438 _id: {$gte: null}
439 }
440 }).then(function (response) {
441 response.docs.map(function (doc) {
442 return doc._id;
443 }).sort().should.deep.equal(
444 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
445 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
446 'yoshi']
447 );
448 });
449 });
450 });
451
452 it('should query all docs with $gt: null', function () {
453 var db = context.db;
454 return db.bulkDocs(
455 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
456 ).then(function () {
457 return db.find({
458 sort: [{_id: 'desc'}], selector: {
459 _id: {$gt: null}
460 }
461 }).then(function (response) {
462 response.docs.map(function (doc) {
463 return doc._id;
464 }).sort().should.deep.equal(
465 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
466 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
467 'yoshi']
468 );
469 });
470 });
471 });
472
473 it('should query all docs with $lt: false', function () {
474 var db = context.db;
475 return db.bulkDocs(
476 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
477 ).then(function () {
478 return db.find({
479 sort: [{_id: 'desc'}], selector: {
480 _id: {$lt: false}
481 }
482 }).then(function (response) {
483 response.docs.should.deep.equal([]);
484 });
485 });
486 });
487
488 it('should query all docs with $lt: {}', function () {
489 var db = context.db;
490 return db.bulkDocs(
491 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
492 ).then(function () {
493 return db.find({
494 sort: [{_id: 'desc'}], selector: {
495 _id: {$lt: {}}
496 }
497 }).then(function (response) {
498 response.docs.should.deep.equal([]);
499 });
500 });
501 });
502
503 it('should query all docs with $lte: {}', function () {
504 var db = context.db;
505 return db.bulkDocs(
506 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
507 ).then(function () {
508 return db.find({
509 sort: [{_id: 'desc'}], selector: {
510 _id: {$lte: {}}
511 }
512 }).then(function (response) {
513 response.docs.should.deep.equal([]);
514 });
515 });
516 });
517
518 it('should query all docs with $lte: []', function () {
519 var db = context.db;
520 return db.bulkDocs(
521 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
522 ).then(function () {
523 return db.find({
524 sort: [{_id: 'desc'}], selector: {
525 _id: {$lte: []}
526 }
527 }).then(function (response) {
528 response.docs.should.deep.equal([]);
529 });
530 });
531 });
532
533 it('should query all docs with $lte: null', function () {
534 var db = context.db;
535 return db.bulkDocs(
536 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
537 ).then(function () {
538 return db.find({
539 sort: [{_id: 'desc'}], selector: {
540 _id: {$lte: null}
541 }
542 }).then(function (response) {
543 response.docs.should.deep.equal([]);
544 });
545 });
546 });
547
548 it('should query all docs with $lt: null', function () {
549 var db = context.db;
550 return db.bulkDocs(
551 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
552 ).then(function () {
553 return db.find({
554 sort: [{_id: 'desc'}], selector: {
555 _id: {$lt: null}
556 }
557 }).then(function (response) {
558 response.docs.should.deep.equal([]);
559 });
560 });
561 });
562
563 it('should query all docs with $gt: false', function () {
564 var db = context.db;
565 return db.bulkDocs(
566 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
567 ).then(function () {
568 return db.find({
569 sort: [{_id: 'desc'}], selector: {
570 _id: {$gt: false}
571 }
572 }).then(function (response) {
573 response.docs.map(function (doc) {
574 return doc._id;
575 }).sort().should.deep.equal(
576 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
577 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
578 'yoshi']
579 );
580 });
581 });
582 });
583
584 it('should query all docs with $gte: 0', function () {
585 var db = context.db;
586 return db.bulkDocs(
587 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
588 ).then(function () {
589 return db.find({
590 sort: [{_id: 'desc'}], selector: {
591 _id: {$gte: 0}
592 }
593 }).then(function (response) {
594 response.docs.map(function (doc) {
595 return doc._id;
596 }).sort().should.deep.equal(
597 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
598 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
599 'yoshi']
600 );
601 });
602 });
603 });
604
605 it('should query all docs with $gt: 0', function () {
606 var db = context.db;
607 return db.bulkDocs(
608 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
609 ).then(function () {
610 return db.find({
611 sort: [{_id: 'desc'}], selector: {
612 _id: {$gt: 0}
613 }
614 }).then(function (response) {
615 response.docs.map(function (doc) {
616 return doc._id;
617 }).sort().should.deep.equal(
618 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
619 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
620 'yoshi']
621 );
622 });
623 });
624 });
625
626 it('should query all docs with $gte: false', function () {
627 var db = context.db;
628 return db.bulkDocs(
629 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
630 ).then(function () {
631 return db.find({
632 sort: [{_id: 'desc'}], selector: {
633 _id: {$gte: false}
634 }
635 }).then(function (response) {
636 response.docs.map(function (doc) {
637 return doc._id;
638 }).sort().should.deep.equal(
639 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
640 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
641 'yoshi']
642 );
643 });
644 });
645 });
646
647 it('should query all docs with $gt: {}', function () {
648 var db = context.db;
649 return db.bulkDocs(
650 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
651 ).then(function () {
652 return db.find({
653 sort: [{_id: 'desc'}], selector: {
654 _id: {$gt: {}}
655 }
656 }).then(function (response) {
657 response.docs.map(function (doc) {
658 return doc._id;
659 }).sort().should.deep.equal(
660 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
661 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
662 'yoshi']
663 );
664 });
665 });
666 });
667
668 it('should query all docs with $gte: {}', function () {
669 var db = context.db;
670 return db.bulkDocs(
671 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
672 ).then(function () {
673 return db.find({
674 sort: [{_id: 'desc'}], selector: {
675 _id: {$gte: {}}
676 }
677 }).then(function (response) {
678 response.docs.map(function (doc) {
679 return doc._id;
680 }).sort().should.deep.equal(
681 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
682 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
683 'yoshi']
684 );
685 });
686 });
687 });
688
689 it('should query all docs with $eq: {}', function () {
690 var db = context.db;
691 return db.bulkDocs(
692 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
693 ).then(function () {
694 return db.find({
695 sort: [{_id: 'desc'}], selector: {
696 _id: {$eq: {}}
697 }
698 }).then(function (response) {
699 response.docs.should.deep.equal([]);
700 });
701 });
702 });
703
704 it('should query all docs with $eq: null', function () {
705 var db = context.db;
706 return db.bulkDocs(
707 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
708 ).then(function () {
709 return db.find({
710 sort: [{_id: 'desc'}], selector: {
711 _id: {$eq: null}
712 }
713 }).then(function (response) {
714 response.docs.should.deep.equal([]);
715 });
716 });
717 });
718
719 it('should query all docs with $eq: 0', function () {
720 var db = context.db;
721 return db.bulkDocs(
722 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
723 ).then(function () {
724 return db.find({
725 sort: [{_id: 'desc'}], selector: {
726 _id: {$eq: 0}
727 }
728 }).then(function (response) {
729 response.docs.should.deep.equal([]);
730 });
731 });
732 });
733
734 it('should query all docs with $eq: null', function () {
735 var db = context.db;
736 return db.bulkDocs(
737 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
738 ).then(function () {
739 return db.find({
740 sort: [{_id: 'desc'}], selector: {
741 _id: {$eq: null}
742 }
743 }).then(function (response) {
744 response.docs.should.deep.equal([]);
745 });
746 });
747 });
748
749 it('should query all docs with $lte: 0', function () {
750 var db = context.db;
751 return db.bulkDocs(
752 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
753 ).then(function () {
754 return db.find({
755 sort: [{_id: 'desc'}], selector: {
756 _id: {$lte: 0}
757 }
758 }).then(function (response) {
759 response.docs = response.docs.map(function (doc) {
760 return doc._id;
761 });
762 response.docs.should.deep.equal([]);
763 });
764 });
765 });
766
767 it('should query all docs with $gte: null', function () {
768 var db = context.db;
769 return db.bulkDocs(
770 [{_id: 'a'}, {_id: 'b'}, {_id: 'c'}]
771 ).then(function () {
772 return db.find({
773 sort: [{_id: 'desc'}], selector: {
774 _id: {$gte: null}
775 }
776 }).then(function (response) {
777 response.docs.map(function (doc) {
778 return doc._id;
779 }).sort().should.deep.equal(
780 ['a', 'b', 'c', 'dk', 'falcon', 'fox', 'kirby', 'link', 'luigi',
781 'mario', 'master_hand', 'ness', 'pikachu', 'puff', 'samus',
782 'yoshi']
783 );
784 });
785 });
786 });
787 });
788};
\No newline at end of file