root-nomount.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var tap = require("tap")
  2. var origCwd = process.cwd()
  3. process.chdir(__dirname)
  4. tap.test("changing root and searching for /b*/**", function (t) {
  5. var glob = require('../')
  6. var path = require('path')
  7. t.test('.', function (t) {
  8. glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) {
  9. t.ifError(er)
  10. t.like(matches, [])
  11. t.end()
  12. })
  13. })
  14. t.test('a', function (t) {
  15. glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) {
  16. t.ifError(er)
  17. t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
  18. t.end()
  19. })
  20. })
  21. t.test('root=a, cwd=a/b', function (t) {
  22. glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) {
  23. t.ifError(er)
  24. t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
  25. t.end()
  26. })
  27. })
  28. t.test('cd -', function (t) {
  29. process.chdir(origCwd)
  30. t.end()
  31. })
  32. t.end()
  33. })