test.js 1014 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var gp = require('./');
  3. var assert = require('assert');
  4. describe('glob-parent', function() {
  5. it('should strip glob magic to return parent path', function() {
  6. assert.equal(gp('path/to/*.js'), 'path/to');
  7. assert.equal(gp('/root/path/to/*.js'), '/root/path/to');
  8. assert.equal(gp('/*.js'), '/');
  9. assert.equal(gp('*.js'), '.');
  10. assert.equal(gp('**/*.js'), '.');
  11. assert.equal(gp('path/{to,from}'), 'path');
  12. assert.equal(gp('path/!(to|from)'), 'path');
  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/**/*'), 'path');
  18. assert.equal(gp('path/**/subdir/foo.*'), 'path');
  19. });
  20. it('should return parent dirname from non-glob paths', function() {
  21. assert.equal(gp('path/foo/bar.js'), 'path/foo');
  22. assert.equal(gp('path/foo/'), 'path/foo');
  23. assert.equal(gp('path/foo'), 'path');
  24. });
  25. });