@@ -11,7 +11,10 @@ describe 'PathWatcher', ->
1111
1212 beforeEach ->
1313 fs .writeFileSync (tempFile, ' ' )
14-
14+ @ addMatchers {
15+ toBeAnyOf : (expectedValues ) ->
16+ @actual in expectedValues
17+ }
1518 afterEach ->
1619 pathWatcher .closeAllWatchers ()
1720
@@ -36,7 +39,7 @@ describe 'PathWatcher', ->
3639 expect (pathWatcher .getWatchedPaths ()).toEqual []
3740
3841 describe ' when a watched path is changed' , ->
39- it ' fires the callback with the event type and empty path' , ->
42+ it ' fires the callback with the event type and path' , ->
4043 eventType = null
4144 eventPath = null
4245 watcher = pathWatcher .watch tempFile, (type , path ) ->
@@ -47,7 +50,7 @@ describe 'PathWatcher', ->
4750 waitsFor -> eventType?
4851 runs ->
4952 expect (eventType).toBe ' change'
50- expect (eventPath).toBe ' '
53+ expect (eventPath).toBe tempFile
5154
5255 describe ' when a watched path is renamed #darwin #win32' , ->
5356 it ' fires the callback with the event type and new path and watches the new path' , ->
@@ -75,32 +78,32 @@ describe 'PathWatcher', ->
7578 waitsFor -> deleted
7679
7780 describe ' when a file under watched directory is deleted' , ->
78- it ' fires the callback with the change event and empty path' , (done ) ->
81+ it ' fires the callback with the change event and path' , (done ) ->
7982 fileUnderDir = path .join (tempDir, ' file' )
8083 fs .writeFileSync (fileUnderDir, ' ' )
8184 watcher = pathWatcher .watch tempDir, (type , path ) ->
8285 expect (type).toBe ' change'
83- expect (path).toBe ' '
86+ expect (path).toBe fileUnderDir
8487 done ()
8588 fs .unlinkSync (fileUnderDir)
8689
8790 describe ' when a new file is created under watched directory' , ->
88- it ' fires the callback with the change event and empty path' , ->
91+ it ' fires the callback with the change event and path' , ->
8992 newFile = path .join (tempDir, ' file' )
9093 watcher = pathWatcher .watch tempDir, (type , path ) ->
9194 fs .unlinkSync (newFile)
9295
9396 expect (type).toBe ' change'
94- expect (path).toBe ' '
97+ expect (path).toBe newFile
9598 done ()
9699 fs .writeFileSync (newFile, ' ' )
97100
98101 describe ' when a file under watched directory is moved' , ->
99- it ' fires the callback with the change event and empty path ' , (done ) ->
102+ it ' fires the callback with the change event and both paths ' , (done ) ->
100103 newName = path .join (tempDir, ' file2' )
101104 watcher = pathWatcher .watch tempDir, (type , path ) ->
102105 expect (type).toBe ' change'
103- expect (path).toBe ' '
106+ expect (path).toBeAnyOf [tempFile, newName]
104107 done ()
105108 fs .renameSync (tempFile, newName)
106109
0 commit comments