Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update find-up, add tests for undefined result (#7)
- Loading branch information
1 parent
1f5dc16
commit aba58d7
Showing
3 changed files
with
17 additions
and
3 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
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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import tempy from 'tempy'; | ||
import pkgDir from '.'; | ||
|
||
// Create a disjoint directory, used for the not-found tests | ||
test.beforeEach(t => { | ||
t.context.disjoint = tempy.directory(); | ||
}); | ||
|
||
test.afterEach(t => { | ||
fs.rmdirSync(t.context.disjoint); | ||
}); | ||
|
||
test('async', async t => { | ||
t.is(await pkgDir(path.join(__dirname, 'fixture')), __dirname); | ||
t.is(await pkgDir(t.context.disjoint), undefined); | ||
}); | ||
|
||
test('sync', t => { | ||
t.is(pkgDir.sync(path.join(__dirname, 'fixture')), __dirname); | ||
t.is(pkgDir.sync(t.context.disjoint), undefined); | ||
}); |