Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for ignoreInitial option.

  • Loading branch information...
commit 268bdfad1e959d9152d75b98bf25ad36906faf78 1 parent 84162ce
Friedel Ziegelmayer Dignifiedquire authored
Showing with 45 additions and 2 deletions.
  1. +45 −2 test/chokidar-test.coffee
47 test/chokidar-test.coffee
View
@@ -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', ->
@@ -15,8 +17,6 @@ describe 'chokidar', ->
describe 'watch', ->
options = {}
- delay = (fn) =>
- setTimeout fn, 205
beforeEach (done) ->
@watcher = chokidar.watch fixturesPath, options
@@ -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'

2 comments on commit 268bdfa

asadz31

Why you chose a Bengali word to name the module, just curious.

Paul Miller
Owner

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

Please sign in to comment.
Something went wrong with that request. Please try again.