Skip to content

Commit

Permalink
Add tests for ignoreInitial option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Friedel Ziegelmayer committed Mar 19, 2013
1 parent 84162ce commit 268bdfa
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions test/chokidar-test.coffee
Expand Up @@ -7,6 +7,8 @@ getFixturePath = (subPath) ->
sysPath.join __dirname, 'fixtures', subPath

fixturesPath = getFixturePath ''
delay = (fn) =>
setTimeout fn, 205

describe 'chokidar', ->
it 'should expose public API methods', ->
Expand All @@ -15,8 +17,6 @@ describe 'chokidar', ->

describe 'watch', ->
options = {}
delay = (fn) =>
setTimeout fn, 205

beforeEach (done) ->
@watcher = chokidar.watch fixturesPath, options
Expand Down Expand Up @@ -114,6 +114,49 @@ describe 'chokidar', ->
spy.should.have.been.calledWith testPath
done()


describe 'watch options', ->
describe 'ignoreInitial', ->
options = { ignoreInitial: yes }

before (done) ->
try fs.unlinkSync getFixturePath('subdir/add.txt')
try fs.rmdirSync getFixturePath('subdir')
done()

after (done) ->
try fs.unlinkSync getFixturePath('subdir/add.txt')
try fs.rmdirSync getFixturePath('subdir')
done()

it 'should ignore inital add events', (done) ->
spy = sinon.spy()
watcher = chokidar.watch fixturesPath, options
watcher.on 'add', spy
delay ->
spy.should.not.have.been.called
watcher.close()
done()

it 'should notice when a file appears in an empty directory', (done) ->
spy = sinon.spy()
testDir = getFixturePath 'subdir'
testPath = getFixturePath 'subdir/add.txt'

watcher = chokidar.watch fixturesPath, options
watcher.on 'add', spy

delay ->
spy.should.not.have.been.called
fs.mkdirSync testDir, 0o755
watcher.add testDir

fs.writeFileSync testPath, 'hello'
delay ->
spy.should.have.been.calledOnce
spy.should.have.been.calledWith testPath
done()

describe 'is-binary', ->
it 'should be a function', ->
isBinary.should.be.a 'function'
Expand Down

1 comment on commit 268bdfa

@paulmillr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chokidar [en] - / noun / guard, keeper, watch, caretaker, janitor, chokidar

Please sign in to comment.