Skip to content

Commit

Permalink
Use platform-agnostic separators
Browse files Browse the repository at this point in the history
  • Loading branch information
atjn committed Jul 20, 2024
1 parent 19e4ddc commit 97f708c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec as execCallback } from "node:child_process";
import { join as joinPaths, dirname as pathDirname } from "node:path";
import { join as joinPaths, dirname as pathDirname, sep } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import tap from "tap";
Expand All @@ -21,10 +21,10 @@ const cwd = joinPaths(dirname, "..");
const sizeOfFixtureFolder = "0.01 MB";

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

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

Expand All @@ -36,14 +36,17 @@ for (const folderArg of ["--folder=", "-f=", ""]) {

for (const ignoreArg of ["--ignore=", "-i="]) {
for (const flipArgs of [false, true]) {
const arg1 = `${folderArg}test/fixture`;
const arg1 = `${folderArg}test${sep}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/get-folder-size.js ${args}`, {
cwd,
});
const result = await exec(
`bin${sep}get-folder-size.js ${args}`,
{
cwd,
},
);

tap.ok(
result.stdout.startsWith("0.00 MB"),
Expand All @@ -56,6 +59,6 @@ for (const folderArg of ["--folder=", "-f=", ""]) {

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

0 comments on commit 97f708c

Please sign in to comment.