-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
48 lines (40 loc) · 1.42 KB
/
test.js
File metadata and controls
48 lines (40 loc) · 1.42 KB
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
45
46
47
48
var Cache = require('./index.js');
describe ('index', function () {
var db = 'fooDB';
var store = {name: 'barStore'};
var keyStore = {name: 'storeWithKey', keyPath : 'id'};
beforeEach(function () {
this.cache = new Cache();
this.cache.init(db, [store, keyStore]);
});
it ( 'should delete', function (done) {
var _this = this;
this.cache.put(store.name, {sap : 'dap', fap : 'bap'}, function (key) {
var putKey = key;
_this.cache.delete(store.name, putKey, function (res) {
_this.cache.findOne(store.name, putKey, function (res) {
expect(res).to.be.undefined;
done();
});
})
})
});
it ('should put an object in the store', function (done) {
var _this = this;
this.cache.put(store.name, {sap : 'dap'}, function (key) {
_this.cache.find(store.name, function (res) {
expect(res[0].sap).to.equal('dap');
done();
})
})
});
it ( 'should retrieve one object from the store', function (done) {
var _this = this;
this.cache.put(keyStore.name, {fooer : 'barers', id : '1337'}, function () {
_this.cache.findOne(keyStore.name, '1337', function (res) {
expect(res.fooer).to.equal('barers')
done();
});
});
})
})