/
isDirectoryPath.test.mjs
45 lines (39 loc) · 1.12 KB
/
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
40
41
42
43
44
45
// @ts-check
import { rejects, strictEqual } from "node:assert";
import { fileURLToPath } from "node:url";
import isDirectoryPath from "./isDirectoryPath.mjs";
/**
* Adds `isDirectoryPath` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add(
"`isDirectoryPath` with 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.")
);
}
);
tests.add("`isDirectoryPath` with a directory path.", async () => {
strictEqual(
await isDirectoryPath(fileURLToPath(new URL("./", import.meta.url))),
true
);
});
tests.add("`isDirectoryPath` with a file path.", async () => {
strictEqual(await isDirectoryPath(fileURLToPath(import.meta.url)), false);
});
tests.add("`isDirectoryPath` with a nonexistent path.", async () => {
strictEqual(
await isDirectoryPath(
fileURLToPath(new URL("nonexistent", import.meta.url))
),
false
);
});
};