-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathisDirectoryPath.test.mjs
39 lines (33 loc) · 979 Bytes
/
isDirectoryPath.test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// @ts-check
import { rejects, strictEqual } from "node:assert";
import { describe, it } from "node:test";
import { fileURLToPath } from "node:url";
import isDirectoryPath from "./isDirectoryPath.mjs";
describe("Function `isDirectoryPath`.", { concurrency: true }, () => {
it("Argument 1 `path` not a string.", async () => {
await rejects(
isDirectoryPath(
// @ts-expect-error Testing invalid.
true,
),
new TypeError("Argument 1 `path` must be a string."),
);
});
it("Directory path.", async () => {
strictEqual(
await isDirectoryPath(fileURLToPath(new URL("./", import.meta.url))),
true,
);
});
it("File path.", async () => {
strictEqual(await isDirectoryPath(fileURLToPath(import.meta.url)), false);
});
it("Nonexistent path.", async () => {
strictEqual(
await isDirectoryPath(
fileURLToPath(new URL("nonexistent", import.meta.url)),
),
false,
);
});
});