Skip to content

Commit 2f36351

Browse files
authored
Merge pull request #5 from Teamwork/fix-tests
Fix tests
2 parents aaf2881 + 6fe52da commit 2f36351

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: node_js
22
node_js:
3-
- 9
4-
- 8
5-
- 6
6-
- 4
3+
- "10"
4+
- "8"
5+
- "6"
76
script: "npm run test-cover"
87
# Send coverage data to Coveralls
98
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"coveralls": "^2.11.8",
1717
"expect.js": "^0.3.1",
1818
"istanbul": "^0.4.2",
19-
"mocha": "^2.3.3"
19+
"mocha": "^2.3.3",
20+
"sharedb": "^1.0.0-beta"
2021
},
2122
"author": "Avital Oliver",
2223
"license": "MIT",
@@ -25,7 +26,9 @@
2526
},
2627
"homepage": "https://github.com/share/sharedb-mingo-memory#readme",
2728
"dependencies": {
28-
"mingo": "^2.2.0",
29+
"mingo": "^2.2.0"
30+
},
31+
"peerDependencies": {
2932
"sharedb": "^1.0.0-beta"
3033
}
3134
}

test/query.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
var expect = require('expect.js');
22
var async = require('async');
33

4+
var sortSnapshot = function(snapshots) {
5+
return snapshots.sort(function (a, b) {
6+
return (a.id > b.id) ? 1 : ((b.id > a.id) ? -1 : 0);
7+
});
8+
}
9+
410
// Call this function inside a `describe` block. Assumes that
511
// `this.db` is set to be a ShareDB instance that supports certain
612
// Mongo queries.
@@ -109,7 +115,7 @@ module.exports = function() {
109115
it('top-level boolean operator', function(done) {
110116
this.db.query('testcollection', {$or: [{y: 1}, {_id: 'test2'}]}, null, null, function(err, results, extra) {
111117
if (err) throw err;
112-
expect(results).eql([snapshotsNoMeta[0], snapshotsNoMeta[1]]);
118+
expect(sortSnapshot(results)).eql(sortSnapshot([snapshotsNoMeta[0], snapshotsNoMeta[1]]));
113119
done();
114120
});
115121
});
@@ -162,7 +168,7 @@ module.exports = function() {
162168
it('$or', function(done) {
163169
this.db.query('testcollection', {$or: [{x: 1}, {y: 1}], $sort: {_id: 1}}, null, null, function(err, results, extra) {
164170
if (err) throw err;
165-
expect(results).eql([snapshots[0], snapshots[1]]);
171+
expect(sortSnapshot(results)).eql(sortSnapshot([snapshots[0], snapshots[1]]));
166172
done();
167173
});
168174
});

0 commit comments

Comments
 (0)