-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new unit testing for new feature surface
- Loading branch information
1 parent
127847a
commit 729f535
Showing
2 changed files
with
238 additions
and
96 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
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,92 @@ | ||
import { Test } from 'nodeunit'; | ||
import path = require('path'); | ||
import util = require('../../lib/fs/utils'); | ||
import { FollowMode } from '../../lib/fs'; | ||
|
||
export = { | ||
shouldExclude: { | ||
'excludes nothing by default'(test: Test) { | ||
test.ok(!util.shouldExclude([], path.join('some', 'file', 'path'))); | ||
test.done(); | ||
}, | ||
|
||
'excludes requested files'(test: Test) { | ||
const exclusions = ['*.ignored']; | ||
test.ok(util.shouldExclude(exclusions, path.join('some', 'file.ignored'))); | ||
test.ok(!util.shouldExclude(exclusions, path.join('some', 'important', 'file'))); | ||
test.done(); | ||
}, | ||
|
||
'does not exclude whitelisted files'(test: Test) { | ||
const exclusions = ['*.ignored', '!important.*']; | ||
test.ok(!util.shouldExclude(exclusions, path.join('some', 'important.ignored'))); | ||
test.done(); | ||
}, | ||
}, | ||
|
||
shouldFollow: { | ||
always: { | ||
'follows internal'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join(sourceRoot, 'referent'); | ||
test.ok(util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
|
||
'follows external'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join('alternate', 'referent'); | ||
test.ok(util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
}, | ||
|
||
external: { | ||
'does not follow internal'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join(sourceRoot, 'referent'); | ||
test.ok(!util.shouldFollow(FollowMode.External, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
|
||
'follows external'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join('alternate', 'referent'); | ||
test.ok(util.shouldFollow(FollowMode.External, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
}, | ||
|
||
blockExternal: { | ||
'follows internal'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join(sourceRoot, 'referent'); | ||
test.ok(!util.shouldFollow(FollowMode.Never, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
|
||
'does not follow external'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join('alternate', 'referent'); | ||
test.ok(!util.shouldFollow(FollowMode.BlockExternal, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
}, | ||
|
||
never: { | ||
'does not follow internal'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join(sourceRoot, 'referent'); | ||
test.ok(!util.shouldFollow(FollowMode.Never, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
|
||
'does not follow external'(test: Test) { | ||
const sourceRoot = path.join('source', 'root'); | ||
const linkTarget = path.join('alternate', 'referent'); | ||
test.ok(!util.shouldFollow(FollowMode.Never, sourceRoot, linkTarget)); | ||
test.done(); | ||
}, | ||
} | ||
}, | ||
}; |