Skip to content

Commit

Permalink
test: improve watch.
Browse files Browse the repository at this point in the history
  • Loading branch information
StreetStrider committed Feb 26, 2016
1 parent b969cd6 commit 79f7ba3
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/watch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var lib = require('./_lib')
var inst = require('./_inst')
var stream = require('./_stream')

describe('watch', () =>
{
Expand All @@ -15,4 +16,68 @@ describe('watch', () =>
{
inst(watch, 'watch')
})

describe('works', () =>
{
/*
This test case only ensures that stream is working,
it does not test watch engine itself.
The watch functionality provided by `chokidar`,
please consult its tests for details
https://www.npmjs.com/package/chokidar
*/
var lil = __dirname + '/lil-fs'

it('watch(string)', () =>
{
var s = watch('*', { cwd: lil })

setTimeout(() => s.end(true), 250)

return stream.streamEquals(s,
[
[ 'addDir', 'dir' ],
[ 'add', 'file-2.txt' ],
[ 'add', 'file.txt' ]
])
})

it('watch(string)', () =>
{
var s = watch('**/*', { cwd: lil })

setTimeout(() => s.end(true), 250)

return stream.streamEquals(s,
[
[ 'addDir', 'dir' ],
[ 'add', 'file-2.txt' ],
[ 'add', 'file.txt' ],
[ 'add', 'dir/file.txt' ]
])
})

it('watch(array of strings)', () =>
{
var s = watch([ '*.txt', '*/*' ], { cwd: lil })

setTimeout(() => s.end(true), 250)

return stream.streamEquals(s,
[
[ 'add', 'file-2.txt' ],
[ 'add', 'file.txt' ],
[ 'add', 'dir/file.txt' ]
])
})

it('watch(empty array)', () =>
{
var s = watch([], { cwd: lil })

setTimeout(() => s.end(true), 250)

return stream.streamEquals(s, [])
})
})
})

0 comments on commit 79f7ba3

Please sign in to comment.