Skip to content

Commit

Permalink
Add extra tests for path.format
Browse files Browse the repository at this point in the history
  • Loading branch information
elvisvoer committed Jan 21, 2024
1 parent 4d7a305 commit 8716862
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/b-path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,26 @@ describe("b-path", () => {
// should add the extension "." if missing
[{ root: "/root/", name: "file", ext: "txt" }, "/root/file.txt"],
// should ignore 'name' and 'ext' if 'base' is present
[{ root: "/root/", base: "base.sh", name: "file", ext: ".txt" }, "/root/base.sh"],
[
{ root: "/root/", base: "base.sh", name: "file", ext: ".txt" },
"/root/base.sh",
],
// should ignore 'root' if 'dir' is present
[{ root: "/root/", dir: "/dir", base: "file.txt"}, "/dir/file.txt"],
[{ root: "/root/", dir: "/dir", base: "file.txt" }, "/dir/file.txt"],
// additional tests
[{ root: "" }, ""],
[{ dir: "" }, ""],
[{ dir: "." }, "./"],
[{ dir: "/" }, "//"], // really?!
[{ dir: "foo" }, "foo/"],
[{ root: "/", dir: "/" }, "/"], // 'root' === 'dir' so no separator
[{ root: ".", dir: "." }, "."], // same here
[{ root: "/", dir: "./" }, ".//"], // results seem not to be normalized
[{ root: "/", dir: "./", base: "../" }, ".//../"], // same here
[{ ext: "txt" }, ".txt"], // dot is added even when only 'ext' is provided
[{ ext: "." }, "."], // starts with dot so no changes
[{ ext: ".." }, ".."], // same here
[{ ext: "/" }, "./"], // makes no sense but respects the idea of adding a dot
].forEach(([input, result]) => {
it(`path.format(${JSON.stringify(
input
Expand Down

0 comments on commit 8716862

Please sign in to comment.