Improve doesDirectoryExist test
This commit is contained in:
parent
fd83e55188
commit
172eca420d
3 changed files with 14 additions and 14 deletions
12
lib/util.test.js
generated
12
lib/util.test.js
generated
|
|
@ -318,14 +318,14 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
|||
});
|
||||
}
|
||||
(0, ava_1.default)("doesDirectoryExist", async (t) => {
|
||||
const topLevelFile = "top-level-test-file.txt";
|
||||
fs.writeFileSync(topLevelFile, "");
|
||||
// Returns false if file
|
||||
t.false(util.doesDirectoryExist(topLevelFile));
|
||||
// Returns false if no file of this type exists
|
||||
// Returns false if no file/dir of this name exists
|
||||
t.false(util.doesDirectoryExist("non-existent-file.txt"));
|
||||
// Returns true if directory
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
// Returns false if file
|
||||
const testFile = `${tmpDir}/test-file.txt`;
|
||||
fs.writeFileSync(testFile, "");
|
||||
t.false(util.doesDirectoryExist(testFile));
|
||||
// Returns true if directory
|
||||
fs.writeFileSync(`${tmpDir}/nested-test-file.txt`, "");
|
||||
t.true(util.doesDirectoryExist(tmpDir));
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -443,16 +443,16 @@ for (const [
|
|||
}
|
||||
|
||||
test("doesDirectoryExist", async (t) => {
|
||||
const topLevelFile = "top-level-test-file.txt";
|
||||
fs.writeFileSync(topLevelFile, "");
|
||||
// Returns false if file
|
||||
t.false(util.doesDirectoryExist(topLevelFile));
|
||||
|
||||
// Returns false if no file of this type exists
|
||||
// Returns false if no file/dir of this name exists
|
||||
t.false(util.doesDirectoryExist("non-existent-file.txt"));
|
||||
|
||||
// Returns true if directory
|
||||
await util.withTmpDir(async (tmpDir: string) => {
|
||||
// Returns false if file
|
||||
const testFile = `${tmpDir}/test-file.txt`;
|
||||
fs.writeFileSync(testFile, "");
|
||||
t.false(util.doesDirectoryExist(testFile));
|
||||
|
||||
// Returns true if directory
|
||||
fs.writeFileSync(`${tmpDir}/nested-test-file.txt`, "");
|
||||
t.true(util.doesDirectoryExist(tmpDir));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue