Skip to content

Commit

Permalink
format unit tests, add tests for #100
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Sep 8, 2017
1 parent d4d41fd commit 605d4cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
21 changes: 11 additions & 10 deletions test/api.isMatch.js
Expand Up @@ -165,11 +165,20 @@ describe('.isMatch():', function() {
assert(!mm.isMatch('a/z.js', 'a/b/**/*.js'));
assert(!mm.isMatch('z.js', 'a/b/**/*.js'));

// issue #23
// https://github.com/micromatch/micromatch/issues/15
assert(mm.isMatch('z.js', 'z*'));
assert(mm.isMatch('z.js', '**/z*'));
assert(mm.isMatch('z.js', '**/z*.js'));
assert(mm.isMatch('z.js', '**/*.js'));
assert(mm.isMatch('foo', '**/foo'));
});

it('issue #23', function() {
assert(!mm.isMatch('zzjs', 'z*.js'));
assert(!mm.isMatch('zzjs', '*z.js'));
});

// issue #24
it('issue #24', function() {
assert(mm.isMatch('a', '**'));
assert(!mm.isMatch('a', 'a/**'));
assert(mm.isMatch('a/', '**'));
Expand All @@ -188,14 +197,6 @@ describe('.isMatch():', function() {
assert(mm.isMatch('a/b/c/d/e.f', 'a/b/**/d/**/*.*'));
assert(mm.isMatch('a/b/c/d/g/e.f', 'a/b/**/d/**/*.*'));
assert(mm.isMatch('a/b/c/d/g/g/e.f', 'a/b/**/d/**/*.*'));

// https://github.com/micromatch/micromatch/issues/15
assert(mm.isMatch('z.js', 'z*'));
assert(mm.isMatch('z.js', '**/z*'));
assert(mm.isMatch('z.js', '**/z*.js'));
assert(mm.isMatch('z.js', '**/*.js'));
assert(mm.isMatch('foo', '**/foo'));

assert(mm.isMatch('a/b-c/z.js', 'a/b-*/**/z.js'));
assert(mm.isMatch('a/b-c/d/e/z.js', 'a/b-*/**/z.js'));
});
Expand Down
21 changes: 14 additions & 7 deletions test/extglobs.js
Expand Up @@ -17,6 +17,20 @@ describe('extglobs', function() {
path.sep = sep;
});

it('should match extglobs with wildcards (issue #100)', function() {
mm(['foo/bar/baz.jsx'], 'foo/bar/*.+(js|jsx)', ['foo/bar/baz.jsx']);
mm(['foo/bar/baz.jsx'], 'foo/bar/**/*.+(js|jsx)', ['foo/bar/baz.jsx']);
mm(['foo.txt'], '**/!(bar).txt', ['foo.txt']);
mm(['a/dir/foo.txt'], '*/dir/**/!(bar).txt', ['a/dir/foo.txt']);
mm(['a/b/c.txt', 'a/b/cc.txt'], '*/b/!(c).txt', []);
mm(['a/b/c.txt', 'a/b/cc.txt'], '*/b/!(*).txt', []);
mm(['a/b/c.txt', 'a/b/cc.txt'], '*/b/!(cc).txt', ['a/b/c.txt']);
mm(['b/c', 'b/cc'], 'b/!(cc)', ['b/c']);
mm(['b/c', 'b/ccc', 'b/cc'], 'b/!(c)', ['b/cc', 'b/ccc']);
mm(['b/c.txt', 'b/cc.txt'], 'b/!(cc).txt', ['b/c.txt']);
mm(['b/c.txt', 'b/cc.txt'], 'b/!(c).txt', []);
});

it('should match extglobs ending with statechar', function() {
// from minimatch tests
assert(!mm.isMatch('ax', 'a?(b*)'));
Expand Down Expand Up @@ -49,13 +63,6 @@ describe('extglobs', function() {
mm(['a.js', 'a.txt', 'a.md'], 'a.!(js)*', ['a.md', 'a.txt']);
});

it('handles extglobs and patterns, issues 100, 102, 103', function() {
mm(['foo/MyDir/MyFile.jsx'], 'foo/MyDir/**/*.+(js|jsx)', ['foo/MyDir/MyFile.jsx']);
mm(['file.txt'], '**/!(folder).txt', ['file.txt']);
mm(['a/dir/file.txt'], '*/dir/**/!(folder).txt', ['a/dir/file.txt']);
mm(['a/b/c.txt', 'a/b/cc.txt'], '*/b/!(c).txt', ['a/b/cc.txt']);
});

it('should support negation', function() {
var arr = ['a', 'b', 'aa', 'ab', 'bb', 'ac', 'aaa', 'aab', 'abb', 'ccc'];
mm(arr, '!(a)*', ['b', 'bb', 'ccc']);
Expand Down

0 comments on commit 605d4cf

Please sign in to comment.