forked from marcuswestin/store.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v1-backcompat_test.js
44 lines (40 loc) · 1.4 KB
/
v1-backcompat_test.js
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
module.exports = {
plugin: require('./v1-backcompat'),
setup: setup,
}
function setup(store) {
test('backwards compatability with v1', function() {
store.clear()
assert(typeof store.disabled == 'boolean')
assert(typeof store.enabled == 'boolean')
assert(typeof store.version == 'string')
assert(typeof store.set == 'function')
assert(typeof store.get == 'function')
assert(typeof store.has == 'function')
assert(typeof store.remove == 'function')
assert(typeof store.clear == 'function')
assert(typeof store.transact == 'function')
assert(typeof store.getAll == 'function')
assert(typeof store.forEach == 'function')
assert(typeof store.serialize == 'function')
assert(typeof store.deserialize == 'function')
store.transact('foosact', function(val) {
assert(typeof val == 'object', "new key is not an object at beginning of transaction")
val.foo = 'foo'
})
store.transact('foosact', function(val) {
assert(val.foo == 'foo', "first transaction did not register")
val.bar = 'bar'
})
assert(store.getAll().foosact.foo == 'foo')
var wasCalled = false
store.forEach(function(key, val) {
wasCalled = true
assert(key == 'foosact')
assert(val.foo == 'foo')
})
assert(wasCalled)
assert(store.serialize({}) == '{}')
assert(store.get('foosact').bar == 'bar', "second transaction did not register")
})
}