-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#59] Add tests for the optional extensions parameter
- Loading branch information
1 parent
608ebe5
commit 8b8744f
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var assert = require('assert'); | ||
var requireDir = require('..'); | ||
|
||
// first test regularly: | ||
assert.deepEqual(requireDir('./simple'), { | ||
a: 'a', | ||
b: 'b', | ||
}); | ||
|
||
// only js files | ||
assert.deepEqual(requireDir('./simple', {extensions: ['.js']}), { | ||
a: 'a' | ||
}); | ||
|
||
// both js and json files | ||
assert.deepEqual(requireDir('./simple', {extensions: ['.js', '.json']}), { | ||
a: 'a', | ||
b: 'b' | ||
}); | ||
|
||
// then test with recursing: | ||
assert.deepEqual(requireDir('./recurse', {recurse: true, extensions: ['.js']}), { | ||
a: 'a', | ||
b: { | ||
'1': { | ||
foo: 'foo' | ||
}, | ||
'2': {} // note how the directory is always returned | ||
}, | ||
c: {} | ||
// note that node_modules was explicitly ignored | ||
}); | ||
|
||
console.log('Extensions tests passed.'); |