-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
44 lines (37 loc) · 1.38 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
// TODO: Should replace this with mocha tests
var MockDB = require('./mockDB');
var mockDB = new MockDB();
var coll1 = mockDB.addCollection("test");
mockDB.collection('test', function(err, coll) {
var testDocument1 = {
name: 'Test document 1',
shouldFind: false
};
var testDocument2 = {
name: 'Test document 2',
shouldFind: true
};
coll.insert(testDocument1, function(err, res) {
if (res.length == 1) {
console.log('Successfully inserted first test document');
coll.insert(testDocument2, function(err, res) {
if (res.length == 1) {
console.log('Successfully inserted second test document');
coll.find({ shouldFind: true }, function(err, res) {
if (res.length == 1) {
console.log('Successfully found second inserted document:');
console.log(res[0]);
} else {
console.log('Failed to find second inserted document');
}
process.exit();
});
} else {
console.log('Failed to insert second document');
}
});
} else {
console.log('Failed to insert first document');
}
});
})