diff --git a/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js b/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js index e24618dc..fc45205a 100644 --- a/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js +++ b/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js @@ -9,6 +9,8 @@ 'use strict'; jest + .dontMock('util') + .dontMock('events') .dontMock('../') .dontMock('q') .setMock( @@ -38,6 +40,21 @@ describe('FileWatcher', function() { }); }); + pit('should emit events', function() { + var cb; + Watcher.prototype.on.mockImplementation(function(type, callback) { + cb = callback; + }); + var fileWatcher = new FileWatcher(['rootDir']); + var handler = jest.genMockFn(); + fileWatcher.on('all', handler); + return fileWatcher._loading.then(function(){ + cb(1, 2, 3, 4); + jest.runAllTimers(); + expect(handler.mock.calls[0]).toEqual([1, 2, 3, 4]); + }); + }); + pit('it should end the watcher', function() { var fileWatcher = new FileWatcher(['rootDir']); Watcher.prototype.close.mockImplementation(function(callback) { diff --git a/react-packager/src/FileWatcher/index.js b/react-packager/src/FileWatcher/index.js index 86ec962b..af8e4ffd 100644 --- a/react-packager/src/FileWatcher/index.js +++ b/react-packager/src/FileWatcher/index.js @@ -45,8 +45,8 @@ function FileWatcher(rootConfigs) { rootConfigs.map(createWatcher) ).then(function(watchers) { watchers.forEach(function(watcher) { - watcher.on('all', function(type, filepath, root) { - fileWatcher.emit('all', type, filepath, root); + watcher.on('all', function(type, filepath, root, stat) { + fileWatcher.emit('all', type, filepath, root, stat); }); }); return watchers;