3 var gp = require('./');
4 var assert = require('assert');
6 describe('glob-parent', function() {
7 it('should strip glob magic to return parent path', function() {
8 assert.equal(gp('path/to/*.js'), 'path/to');
9 assert.equal(gp('/root/path/to/*.js'), '/root/path/to');
10 assert.equal(gp('/*.js'), '/');
11 assert.equal(gp('*.js'), '.');
12 assert.equal(gp('**/*.js'), '.');
13 assert.equal(gp('path/{to,from}'), 'path');
14 assert.equal(gp('path/!(to|from)'), 'path');
15 assert.equal(gp('path/?(to|from)'), 'path');
16 assert.equal(gp('path/+(to|from)'), 'path');
17 assert.equal(gp('path/*(to|from)'), 'path');
18 assert.equal(gp('path/@(to|from)'), 'path');
19 assert.equal(gp('path/**/*'), 'path');
20 assert.equal(gp('path/**/subdir/foo.*'), 'path');
23 it('should return parent dirname from non-glob paths', function() {
24 assert.equal(gp('path/foo/bar.js'), 'path/foo');
25 assert.equal(gp('path/foo/'), 'path/foo');
26 assert.equal(gp('path/foo'), 'path');