mirror of https://github.com/status-im/metro.git
[react-packager] Fix EISDIR error
This commit is contained in:
parent
28a0a2586d
commit
69ae1bb3b7
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue