-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
92 lines (80 loc) · 2.44 KB
/
test.js
File metadata and controls
92 lines (80 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
require('mocha');
var assert = require('assert');
var isAbsolute = require('is-absolute');
var glob = require('./');
describe('glob', function() {
it('should resolve the absolute path for files returned by glob:', function(cb) {
glob('*.js', function(err, files) {
if (err) return cb(err);
assert(files.length > 0);
assert(isAbsolute(files[0]));
cb();
});
});
it('should support arrays:', function(cb) {
glob(['*.js', '*.md', '!**/test.js'], function(err, files) {
if (err) return cb(err);
assert(files.length > 0);
assert(isAbsolute(files[0]));
cb();
});
});
it('should resolve the absolute path with a cwd:', function(cb) {
var opts = {cwd: 'node_modules/is-absolute'};
glob('*.js', opts, function(err, files) {
if (err) return cb(err);
assert(files.length > 0);
assert(isAbsolute(files[0]));
cb();
});
});
it('should resolve the absolute path to the user home directory:', function(cb) {
glob('*.*', {cwd: '~'}, function(err, files) {
if (err) return cb(err);
assert(files.length > 0);
assert(isAbsolute(files[0]));
cb();
});
});
it('should resolve the absolute path to global npm modules:', function(cb) {
glob('*', {cwd: '@'}, function(err, files) {
if (err) return cb(err);
assert(files.length > 0);
assert(isAbsolute(files[0]));
cb();
});
});
it('should throw an error when a callback is not passed:', function() {
assert.throws(function() {
glob();
});
});
it('should throw an error when invalid args are passed:', function(cb) {
glob(null, function(err, files) {
assert(err);
cb();
});
});
});
describe('glob.sync', function() {
it('should resolve the absolute path for files returned by glob:', function() {
var files = glob.sync('*.js');
assert(files.length > 0);
assert(isAbsolute(files[0]));
});
it('should return the pattern when no matches and nonull is passed:', function() {
var files = glob.sync('*.foo', {nonull: true});
assert(files[0] === '*.foo');
});
it('should resolve the absolute path with a cwd:', function() {
var files = glob.sync('*.js', {cwd: 'node_modules/is-absolute'});
assert(files.length > 0);
assert(isAbsolute(files[0]));
});
it('should throw an error when invalid args are passed:', function() {
assert.throws(function() {
glob.sync();
});
});
});