-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
57 lines (47 loc) · 1.32 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict'
const { test } = require('tap')
const level = require('level-mem')
const Live = require('.')
test('level-live', t => {
const db = level('db')
db.put('m', 'm', () => {
const stream = new Live(db, { gt: 'c' })
stream.once('data', op => {
t.deepEqual(op, { type: 'put', key: 'm', value: 'm' })
stream.once('data', op => {
t.deepEqual(op, { type: 'put', key: 'e', value: 'e' })
stream.once('data', op => {
t.deepEqual(op, { type: 'del', key: 'e' })
stream.once('data', op => {
t.deepEqual(op, { type: 'put', key: 'x', value: 'x' })
stream.once('data', op => {
t.deepEqual(op, { type: 'put', key: 'y', value: 'y' })
stream.once('data', () => t.fail())
stream.destroy()
db.put('z', 'z', () => {
t.end()
})
})
})
db
.batch()
.put('x', 'x')
.put('y', 'y')
.write()
})
db.del('e')
})
db.put('a', 'a')
db.put('e', 'e')
})
})
})
test('no opts', t => {
const db = level('no opts')
const stream = new Live(db)
stream.once('data', op => {
t.deepEqual(op, { type: 'put', key: 'foo', value: 'bar' })
t.end()
})
db.put('foo', 'bar')
})