mirror of https://github.com/seald/nedb
parent
1f282639ac
commit
29db197625
@ -0,0 +1,22 @@ |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>Mocha tests for NeDB</title> |
||||
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css"> |
||||
</head> |
||||
<body> |
||||
<div id="mocha"></div> |
||||
<script src="http://code.jquery.com/jquery-latest.min.js"></script> |
||||
<script src="http://chaijs.com/chai.js"></script> |
||||
<script src="../../node_modules/mocha/mocha.js"></script> |
||||
<script>mocha.setup('bdd')</script> |
||||
<script src="../out/nedb.min.js"></script> |
||||
<script src="nedb-browser.js"></script> |
||||
<script> |
||||
mocha.checkLeaks(); |
||||
mocha.globals(['jQuery']); |
||||
mocha.run(); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -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); |
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
}); |
Loading…
Reference in new issue