Skip to content

Commit

Permalink
[react-packager] Fix EISDIR error
Browse files Browse the repository at this point in the history
  • Loading branch information
Amjad Masad committed Apr 1, 2015
1 parent 28a0a25 commit 69ae1bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions react-packager/src/FileWatcher/__tests__/FileWatcher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
'use strict';

jest
.dontMock('util')
.dontMock('events')
.dontMock('../')
.dontMock('q')
.setMock(
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions react-packager/src/FileWatcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 69ae1bb

Please sign in to comment.