diff --git a/browser-version/test/index.html b/browser-version/test/index.html new file mode 100644 index 0000000..219f1a6 --- /dev/null +++ b/browser-version/test/index.html @@ -0,0 +1,22 @@ + + + + + Mocha tests for NeDB + + + +
+ + + + + + + + + diff --git a/browser-version/test/nedb-browser.js b/browser-version/test/nedb-browser.js new file mode 100644 index 0000000..4fc2e01 --- /dev/null +++ b/browser-version/test/nedb-browser.js @@ -0,0 +1,24 @@ +var assert = chai.assert; +chai.should(); + + +describe('Basic test', function () { + + it('Can create a database, insert some docs and query them', function () { + var db = new Nedb(); + + // Can use callback-less syntax since commands are queued + db.insert({ a: 4 }); + db.insert({ a: 40 }); + db.insert({ a: 400 }); + db.find({ a: { $gt: 36 } }, function (err, docs) { + docs.length.should.equal(2); + + db.find({ a: { $lt: 36 } }, function (err, docs) { + docs.length.should.equal(1); + docs[0].a.should.equal(4); + }); + }); + }); + +});