UNPKG

632 BJavaScriptView Raw
1var tape = require('tape')
2var create = require('./helpers/create')
3
4tape('simple watch', function (t) {
5 const db = create(null)
6
7 var watchEvents = 0
8 db.ready(err => {
9 t.error(err, 'no error')
10 db.watch('/a/path/', () => {
11 if (++watchEvents === 2) {
12 t.end()
13 }
14 })
15 doWrites()
16 })
17
18 function doWrites () {
19 db.writeFile('/a/path/hello', 't1', err => {
20 t.error(err, 'no error')
21 db.writeFile('/b/path/hello', 't2', err => {
22 t.error(err, 'no error')
23 db.writeFile('/a/path/world', 't3', err => {
24 t.error(err, 'no error')
25 })
26 })
27 })
28 }
29})