Initial commit
[yaffs-website] / node_modules / globule / node_modules / glob / test / cwd-test.js
1 var tap = require("tap")
2
3 var origCwd = process.cwd()
4 process.chdir(__dirname)
5
6 tap.test("changing cwd and searching for **/d", function (t) {
7   var glob = require('../')
8   var path = require('path')
9   t.test('.', function (t) {
10     glob('**/d', function (er, matches) {
11       t.ifError(er)
12       t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
13       t.end()
14     })
15   })
16
17   t.test('a', function (t) {
18     glob('**/d', {cwd:path.resolve('a')}, function (er, matches) {
19       t.ifError(er)
20       t.like(matches, [ 'b/c/d', 'c/d' ])
21       t.end()
22     })
23   })
24
25   t.test('a/b', function (t) {
26     glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) {
27       t.ifError(er)
28       t.like(matches, [ 'c/d' ])
29       t.end()
30     })
31   })
32
33   t.test('a/b/', function (t) {
34     glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) {
35       t.ifError(er)
36       t.like(matches, [ 'c/d' ])
37       t.end()
38     })
39   })
40
41   t.test('.', function (t) {
42     glob('**/d', {cwd: process.cwd()}, function (er, matches) {
43       t.ifError(er)
44       t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
45       t.end()
46     })
47   })
48
49   t.test('cd -', function (t) {
50     process.chdir(origCwd)
51     t.end()
52   })
53
54   t.end()
55 })