Skip to content

Commit

Permalink
test: add glob2base test patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 authored and phated committed Jan 27, 2021
1 parent f5974fd commit 759bb49
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test.js
Expand Up @@ -26,3 +26,41 @@ describe('glob-parent', function() {
assert.equal(gp('path/foo'), 'path');
});
});

describe('glob2base test patterns', function() {
it('should get a base name', function() {
assert.equal(gp('js/*.js') + '/', 'js/');
});

it('should get a base name from a nested glob', function() {
assert.equal(gp('js/**/test/*.js') + '/', 'js/');
});

it('should get a base name from a flat file', function() {
assert.equal(gp('js/test/wow.js') + '/', 'js/test/');
});

it('should get a base name from character class pattern', function() {
assert.equal(gp('js/t[a-z]st}/*.js') + '/', 'js/');
});

it('should get a base name from brace , expansion', function() {
assert.equal(gp('js/{src,test}/*.js') + '/', 'js/');
});

it('should get a base name from brace .. expansion', function() {
assert.equal(gp('js/test{0..9}/*.js') + '/', 'js/');
});

it('should get a base name from extglob', function() {
assert.equal(gp('js/t+(wo|est)/*.js') + '/', 'js/');
});

it('should get a base name from a complex brace glob', function() {
assert.equal(gp('lib/{components,pages}/**/{test,another}/*.txt') + '/', 'lib/');

assert.equal(gp('js/test/**/{images,components}/*.js') + '/', 'js/test/');

assert.equal(gp('ooga/{booga,sooga}/**/dooga/{eooga,fooga}') + '/', 'ooga/');
});
});

0 comments on commit 759bb49

Please sign in to comment.