mirror of
https://github.com/status-im/metro.git
synced 2025-02-27 18:20:53 +00:00
[react-packager] Fix EISDIR error
This commit is contained in:
parent
28a0a2586d
commit
69ae1bb3b7
@ -9,6 +9,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
|
.dontMock('util')
|
||||||
|
.dontMock('events')
|
||||||
.dontMock('../')
|
.dontMock('../')
|
||||||
.dontMock('q')
|
.dontMock('q')
|
||||||
.setMock(
|
.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() {
|
pit('it should end the watcher', function() {
|
||||||
var fileWatcher = new FileWatcher(['rootDir']);
|
var fileWatcher = new FileWatcher(['rootDir']);
|
||||||
Watcher.prototype.close.mockImplementation(function(callback) {
|
Watcher.prototype.close.mockImplementation(function(callback) {
|
||||||
|
4
react-packager/src/FileWatcher/index.js
vendored
4
react-packager/src/FileWatcher/index.js
vendored
@ -45,8 +45,8 @@ function FileWatcher(rootConfigs) {
|
|||||||
rootConfigs.map(createWatcher)
|
rootConfigs.map(createWatcher)
|
||||||
).then(function(watchers) {
|
).then(function(watchers) {
|
||||||
watchers.forEach(function(watcher) {
|
watchers.forEach(function(watcher) {
|
||||||
watcher.on('all', function(type, filepath, root) {
|
watcher.on('all', function(type, filepath, root, stat) {
|
||||||
fileWatcher.emit('all', type, filepath, root);
|
fileWatcher.emit('all', type, filepath, root, stat);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return watchers;
|
return watchers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user