diff --git a/.travis.yml b/.travis.yml index 9a78f15..4d90f1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: node_js node_js: - - 9 - - 8 - - 6 - - 4 + - "10" + - "8" + - "6" script: "npm run test-cover" # Send coverage data to Coveralls after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/package.json b/package.json index 55040b2..32aa134 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "coveralls": "^2.11.8", "expect.js": "^0.3.1", "istanbul": "^0.4.2", - "mocha": "^2.3.3" + "mocha": "^2.3.3", + "sharedb": "^1.0.0-beta" }, "author": "Avital Oliver", "license": "MIT", @@ -25,7 +26,9 @@ }, "homepage": "https://github.com/share/sharedb-mingo-memory#readme", "dependencies": { - "mingo": "^2.2.0", + "mingo": "^2.2.0" + }, + "peerDependencies": { "sharedb": "^1.0.0-beta" } } diff --git a/test/query.js b/test/query.js index 93cfdc1..ca6355f 100644 --- a/test/query.js +++ b/test/query.js @@ -1,6 +1,12 @@ var expect = require('expect.js'); var async = require('async'); +var sortSnapshot = function(snapshots) { + return snapshots.sort(function (a, b) { + return (a.id > b.id) ? 1 : ((b.id > a.id) ? -1 : 0); + }); +} + // Call this function inside a `describe` block. Assumes that // `this.db` is set to be a ShareDB instance that supports certain // Mongo queries. @@ -109,7 +115,7 @@ module.exports = function() { it('top-level boolean operator', function(done) { this.db.query('testcollection', {$or: [{y: 1}, {_id: 'test2'}]}, null, null, function(err, results, extra) { if (err) throw err; - expect(results).eql([snapshotsNoMeta[0], snapshotsNoMeta[1]]); + expect(sortSnapshot(results)).eql(sortSnapshot([snapshotsNoMeta[0], snapshotsNoMeta[1]])); done(); }); }); @@ -162,7 +168,7 @@ module.exports = function() { it('$or', function(done) { this.db.query('testcollection', {$or: [{x: 1}, {y: 1}], $sort: {_id: 1}}, null, null, function(err, results, extra) { if (err) throw err; - expect(results).eql([snapshots[0], snapshots[1]]); + expect(sortSnapshot(results)).eql(sortSnapshot([snapshots[0], snapshots[1]])); done(); }); });