-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
30 lines (29 loc) · 891 Bytes
/
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
const test = require('tape')
const DB = require('./index.js')
test('indexDb#1', function(t){
t.plan(3)
const db = new DB({key: 'test', initialState: {test: 42}})
db.open()
.then((data) => {
t.equal(data.test, 42, 'open should return the persisted data')
})
.then(() => db.put({test: 43, del: 'useless'}))
.then(() => db.get())
.then(() => db.del('del'))
.then(() => db.get())
.then((d) => t.notOk(d.del))
.then(() => db.get())
.then((data) => t.equal(data.test, 43, 'data should have changed'))
.then(() => t.end())
.catch(console.error)
})
test('indexDb#2', function(t){
t.plan(1)
const db = new DB({key: 'test', initialState: {test: 42}})
db.open()
.then((data) => {
t.equal(data.test, 43, 'open should return the persisted data from before')
})
.then(() => t.end())
.catch(console.error)
})