Skip to content

Commit

Permalink
test: add test when pattern is an array
Browse files Browse the repository at this point in the history
and remove string to array test
  • Loading branch information
weyusi committed Apr 26, 2019
1 parent e23b169 commit ffc2940
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions test/scripts/box/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ describe('Box', () => {
box.base.should.eql(pathFn.join(baseDir, 'foo') + pathFn.sep);
});

it('constructor - make ignore an array if its not one', () => {
const box = newBox('foo', {ignore: 'fooDir'});
box.ignore.should.eql(['fooDir']);
});

it('addProcessor() - no pattern', () => {
const box = newBox();

Expand Down Expand Up @@ -227,7 +222,7 @@ describe('Box', () => {
}).finally(() => fs.rmdir(box.base));
});

it('process() - skip files if they match glob epression in ignore', () => {
it('process() - skip files if they match a glob expression in ignore', () => {
const box = newBox('test', {ignore: '**/ignore_me'});
const data = {};

Expand All @@ -246,6 +241,25 @@ describe('Box', () => {
}).finally(() => fs.rmdir(box.base));
});

it('process() - skip files if they match any of the glob expressions in ignore', () => {
const box = newBox('test', {ignore: ['**/ignore_me', '**/ignore_me_too']});
const data = {};

box.addProcessor(file => {
data[file.path] = file;
});

return Promise.all([
fs.writeFile(pathFn.join(box.base, 'foo.txt'), 'foo'),
fs.writeFile(pathFn.join(box.base, 'ignore_me', 'bar.txt'), 'ignore_me')
]).then(() => box.process()).then(() => {
const keys = Object.keys(data);

keys.length.should.eql(1);
keys[0].should.eql('foo.txt');
}).finally(() => fs.rmdir(box.base));
});

it('watch() - create', () => {
const box = newBox('test');
const path = 'a.txt';
Expand Down

0 comments on commit ffc2940

Please sign in to comment.