-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathhistory.js
60 lines (52 loc) · 1.42 KB
/
history.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const tape = require('tape')
const create = require('./helpers/create')
tape('basic history', function (t) {
const db = create()
db.put('hello', 'world', function (err) {
t.error(err, 'no error')
const ite = db.history()
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data.key, 'hello')
t.same(data.value, 'world')
})
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data, null)
t.end()
})
})
})
tape('multiple entries history', function (t) {
const db = create()
db.put('hello', 'hi', function (err) {
t.error(err, 'no error')
db.put('hi', 'ho', function (err) {
t.error(err, 'no error')
db.put('hello', 'world', function (err) {
t.error(err, 'no error')
const ite = db.history()
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data.key, 'hello')
t.same(data.value, 'hi')
})
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data.key, 'hi')
t.same(data.value, 'ho')
})
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data.key, 'hello')
t.same(data.value, 'world')
})
ite.next(function (err, data) {
t.error(err, 'no error')
t.same(data, null)
t.end()
})
})
})
})
})