Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('all listener is registered after watcher is ready', function () {
var chokidar = require('chokidar');
var Chimp = require('../lib/chimp.js');
var options = {path: 'abc'};
var chimp = new Chimp(options);
chimp.run = jest.genMockFunction();
chokidar.watcher.on = jest.genMockFunction();
chimp.watch();
expect(chokidar.watcher.once.mock.calls[0][0]).toBe('ready');
var readyCallback = chokidar.watcher.once.mock.calls[0][1];
readyCallback();
expect(chokidar.watcher.on.mock.calls[0][0]).toBe('all');
});
it('all listener is registered after watcher is ready', function () {
var chokidar = require('chokidar');
var Chimp = require('../lib/chimp.js');
var options = {path: 'abc'};
var chimp = new Chimp(options);
chimp.run = jest.genMockFunction();
chokidar.watcher.on = jest.genMockFunction();
chimp.watch();
expect(chokidar.watcher.once.mock.calls[0][0]).toBe('ready');
var readyCallback = chokidar.watcher.once.mock.calls[0][1];
readyCallback();
expect(chokidar.watcher.on.mock.calls[0][0]).toBe('all');
});
it('a deleted feature does not trigger the interrupt and run sequence', function () {
var chokidar = require('chokidar');
var Chimp = require('../lib/chimp.js');
//var _on = process.on;
//process.on = jest.genMockFunction();
var chimp = new Chimp();
chimp.run = jest.genMockFunction();
chimp.watch();
var readyCallback = chokidar.watcher.once.mock.calls[0][1];
readyCallback();
var allCallback = chokidar.watcher.on.mock.calls[0][1];
chimp.rerun = jest.genMockFunction();
allCallback('unlink', '/path/some.feature');
expect(chimp.rerun.mock.calls.length).toBe(0);
//process.on = _on;
});
it('all listener is registered after watcher is ready', function () {
var chokidar = require('chokidar');
var Monkey = require('../lib/monkey.js');
var options = {path: 'abc'};
var monkey = new Monkey(options);
monkey.run = jest.genMockFunction();
chokidar.watcher.on = jest.genMockFunction();
monkey.watch();
expect(chokidar.watcher.on.mock.calls[0][0]).toBe('ready');
var readyCallback = chokidar.watcher.on.mock.calls[0][1];
readyCallback();
expect(chokidar.watcher.on.mock.calls[1][0]).toBe('all');
});
var chokidar = require('chokidar');
var Monkey = require('../lib/monkey.js');
var options = {path: 'abc'};
var monkey = new Monkey(options);
monkey.run = jest.genMockFunction();
chokidar.watcher.on = jest.genMockFunction();
monkey.watch();
expect(chokidar.watcher.on.mock.calls[0][0]).toBe('ready');
var readyCallback = chokidar.watcher.on.mock.calls[0][1];
readyCallback();
expect(chokidar.watcher.on.mock.calls[1][0]).toBe('all');
});
var chimp = new Chimp();
chimp.run = jest.genMockFunction();
var self = this;
self.func = null;
self.timeout = null;
chimp._getDebouncedFunction = function(func, timeout) {
self.allCallback = func;
self.timeout = timeout;
};
chimp.watch();
var readyCallback = chokidar.watcher.once.mock.calls[0][1];
readyCallback();
chimp.rerun = jest.genMockFunction();
self.allCallback('not-unlink');
expect(chimp.rerun.mock.calls.length).toBe(1);
});