Skip to content

Commit

Permalink
Skip CLI test on OS with bad separator
Browse files Browse the repository at this point in the history
  • Loading branch information
atjn committed Jul 20, 2024
1 parent 97f708c commit 8caec63
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,56 @@ const exec = promisify(execCallback);
*/
const dirname = pathDirname(fileURLToPath(import.meta.url));

/**
* Skip the test on operating systems with non-standard path separators (Windows).
*/
const skip = sep === "/";

const cwd = joinPaths(dirname, "..");
const sizeOfFixtureFolder = "0.01 MB";

for (const folderArg of ["--folder=", "-f=", ""]) {
const args = `${folderArg}test${sep}fixture`;
const args = `${folderArg}test/fixture`;

tap.test(`get folder size with args: ${args}`, async () => {
const result = await exec(`bin${sep}get-folder-size.js ${args}`, {
const result = await exec(`bin/get-folder-size.js ${args}`, {
cwd,
});

tap.ok(
result.stdout.startsWith(sizeOfFixtureFolder),
"should return the size of the folder",
{ skip },
);
});

for (const ignoreArg of ["--ignore=", "-i="]) {
for (const flipArgs of [false, true]) {
const arg1 = `${folderArg}test${sep}fixture`;
const arg1 = `${folderArg}test/fixture`;
const arg2 = `${ignoreArg}.*txt`;
const args = flipArgs ? `${arg2} ${arg1}` : `${arg1} ${arg2}`;

tap.test(`get folder size with args: ${args}`, async () => {
const result = await exec(
`bin${sep}get-folder-size.js ${args}`,
{
cwd,
},
);
const result = await exec(`bin/get-folder-size.js ${args}`, {
cwd,
});

tap.ok(
result.stdout.startsWith("0.00 MB"),
"should return zero as size",
{ skip },
);
});
}
}
}

tap.test("get folder size with missing args", async () => {
tap.rejects(async () => {
await exec(`bin${sep}get-folder-size.js`, { cwd });
}, "should reject since no folder path is provided");
tap.rejects(
async () => {
await exec("bin/get-folder-size.js", { cwd });
},
"should reject since no folder path is provided",
{ skip },
);
});

0 comments on commit 8caec63

Please sign in to comment.