[react-packager] Fix EISDIR error

This commit is contained in:
Amjad Masad 2015-03-31 20:06:11 -07:00
parent 28a0a2586d
commit 69ae1bb3b7
2 changed files with 19 additions and 2 deletions

View File

@ -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) {

View File

@ -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;