Skip to content

Commit

Permalink
Merge 8b880c8 into db99076
Browse files Browse the repository at this point in the history
  • Loading branch information
JSMonk committed Apr 24, 2019
2 parents db99076 + 8b880c8 commit 0b1a83f
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions test.js
Expand Up @@ -169,9 +169,8 @@ const runTests = function(baseopts) {
watcher.on('add', (path) => {
spy(path);
});
await waitForWatcher(watcher);

await delay();
await waitForWatcher(watcher);

(async () => {
for (let path of paths.slice(0, 5)) {
Expand All @@ -184,6 +183,7 @@ const runTests = function(baseopts) {
delay();
})();

await waitFor([[spy, 4]]);
await waitFor([[spy, 9]]);
paths.forEach(path => {
spy.should.have.been.calledWith(path);
Expand Down Expand Up @@ -278,6 +278,8 @@ const runTests = function(baseopts) {
await write(testg1Path, Date.now());
await write(testh1Path, Date.now());
await write(testi1Path, Date.now());
await waitFor([[spy, 11]]);
await waitFor([[spy, 22]]);
await waitFor([[spy, 33]]);

spy.should.have.been.calledWith(test1Path);
Expand Down Expand Up @@ -757,25 +759,31 @@ const runTests = function(baseopts) {
});
it('should traverse subdirs to match globstar patterns', async () => {
const watchPath = getGlobPath('../../test-*/' + subdirId + '/**/a*.txt');
fs.mkdirSync(getFixturePath('subdir'), PERM_ARR);
fs.mkdirSync(getFixturePath('subdir/subsub'), PERM_ARR);
fs.writeFileSync(getFixturePath('subdir/a.txt'), 'b');
fs.writeFileSync(getFixturePath('subdir/b.txt'), 'b');
fs.writeFileSync(getFixturePath('subdir/subsub/ab.txt'), 'b');
const addFile = getFixturePath('add.txt');
const subdir = getFixturePath('subdir');
const subsubdir = getFixturePath('subdir/subsub');
const aFile = getFixturePath('subdir/a.txt');
const bFile = getFixturePath('subdir/b.txt');
const subFile = getFixturePath('subdir/subsub/ab.txt');
fs.mkdirSync(subdir, PERM_ARR);
fs.mkdirSync(subsubdir, PERM_ARR);
fs.writeFileSync(aFile, 'b');
fs.writeFileSync(bFile, 'b');
fs.writeFileSync(subFile, 'b');

await delay();
let watcher = chokidar_watch(watchPath, options);
const spy = await aspy(watcher, 'all');
setTimeout(async () => {
await write(getFixturePath('add.txt'), Date.now());
await write(getFixturePath('subdir/subsub/ab.txt'), Date.now());
await fs_unlink(getFixturePath('subdir/a.txt'));
await fs_unlink(getFixturePath('subdir/b.txt'));
await write(addFile, Date.now());
await write(subFile, Date.now());
await fs_unlink(aFile);
await fs_unlink(bFile);
}, 50);
await waitFor([[spy.withArgs('add'), 3], spy.withArgs('unlink'), spy.withArgs('change')]);
spy.withArgs('add').should.have.been.calledThrice;
spy.should.have.been.calledWith('unlink', getFixturePath('subdir/a.txt'));
spy.should.have.been.calledWith('change', getFixturePath('subdir/subsub/ab.txt'));
spy.should.have.been.calledWith('unlink', aFile);
spy.should.have.been.calledWith('change', subFile);
spy.withArgs('unlink').should.have.been.calledOnce;
spy.withArgs('change').should.have.been.calledOnce;
});
Expand Down Expand Up @@ -831,8 +839,8 @@ const runTests = function(baseopts) {
spy.should.have.been.calledWith('add', changePath);
spy.should.have.been.calledOnce;

await delay();
await write(changePath, Date.now());
await delay();
await waitFor([[spy, 2]]);
spy.should.have.been.calledWith('change', changePath);
spy.should.have.been.calledTwice;
Expand Down Expand Up @@ -2002,7 +2010,7 @@ const runTests = function(baseopts) {
};

describe('chokidar', function() {
this.timeout(6000);
this.timeout(20000);
before(async () => {
let created = 0;
await rimraf(FIXTURES_PATH);
Expand Down

0 comments on commit 0b1a83f

Please sign in to comment.