-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
95 lines (83 loc) · 2.66 KB
/
test.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
'use strict';
const Parse = require('parse-shim');
const ParseMockDB = require('parse-mockdb');
const StitchQueryP = require('./index');
const expect = require('chai').expect;
class Obj extends Parse.Object {
constructor() {
super('Obj');
}
};
function saveObjsP(count) {
const objsToSave = [];
for (let i=0; i<count; i++) {
const obj = new Obj();
objsToSave.push(obj);
}
return Parse.Object.saveAll(objsToSave);
}
describe('StitchQueryP', function() {
beforeEach(function() {
Parse.MockDB.mockDB();
});
afterEach(function() {
Parse.MockDB.cleanUp();
});
context('when we have exactly 100 objects in collection', function() {
it('returns all of the expected results', function() {
return saveObjsP(100).then((objs) => {
return StitchQueryP(new Parse.Query(Obj))
}).then((results) => {
expect(results).to.have.lengthOf(100);
})
});
});
context('when we have exactly 1000 objects in collection', function() {
it('returns all of the expected results', function() {
return saveObjsP(1000).then((objs) => {
return StitchQueryP(new Parse.Query(Obj))
}).then((results) => {
expect(results).to.have.lengthOf(1000);
})
});
});
context('when we have more than 1000 objects in collection', function() {
it('returns all of the expected results', function() {
return saveObjsP(1001).then((objs) => {
return StitchQueryP(new Parse.Query(Obj))
}).then((results) => {
expect(results).to.have.lengthOf(1001);
})
});
});
context('when we have exactly 10000 objects in collection', function() {
it('returns all of the expected results @slow', function() {
this.timeout(30000);
return saveObjsP(10000).then((objs) => {
return StitchQueryP(new Parse.Query(Obj))
}).then((results) => {
expect(results).to.have.lengthOf(10000);
})
});
});
context('when we have greater than 10000 objects in collection', function() {
it('returns returns only 10k of the expected results @slow', function() {
this.timeout(30000);
return saveObjsP(10100).then((objs) => {
return StitchQueryP(new Parse.Query(Obj))
}).then((results) => {
expect(results).to.have.lengthOf(10000);
})
});
context('using super stitch query', function() {
it('returns all of the expected results @slow', function() {
this.timeout(30000);
return saveObjsP(10100).then((objs) => {
return StitchQueryP(new Parse.Query(Obj), {superStitch: true})
}).then((results) => {
expect(results).to.have.lengthOf(10100);
})
});
});
})
});