You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1014 B
JavaScript
29 lines
1014 B
JavaScript
5 years ago
|
'use strict';
|
||
|
|
||
|
var gp = require('./');
|
||
|
var assert = require('assert');
|
||
|
|
||
|
describe('glob-parent', function() {
|
||
|
it('should strip glob magic to return parent path', function() {
|
||
|
assert.equal(gp('path/to/*.js'), 'path/to');
|
||
|
assert.equal(gp('/root/path/to/*.js'), '/root/path/to');
|
||
|
assert.equal(gp('/*.js'), '/');
|
||
|
assert.equal(gp('*.js'), '.');
|
||
|
assert.equal(gp('**/*.js'), '.');
|
||
|
assert.equal(gp('path/{to,from}'), 'path');
|
||
|
assert.equal(gp('path/!(to|from)'), 'path');
|
||
|
assert.equal(gp('path/?(to|from)'), 'path');
|
||
|
assert.equal(gp('path/+(to|from)'), 'path');
|
||
|
assert.equal(gp('path/*(to|from)'), 'path');
|
||
|
assert.equal(gp('path/@(to|from)'), 'path');
|
||
|
assert.equal(gp('path/**/*'), 'path');
|
||
|
assert.equal(gp('path/**/subdir/foo.*'), 'path');
|
||
|
});
|
||
|
|
||
|
it('should return parent dirname from non-glob paths', function() {
|
||
|
assert.equal(gp('path/foo/bar.js'), 'path/foo');
|
||
|
assert.equal(gp('path/foo/'), 'path/foo');
|
||
|
assert.equal(gp('path/foo'), 'path');
|
||
|
});
|
||
|
});
|