-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCliError.test.mjs
More file actions
29 lines (24 loc) · 753 Bytes
/
CliError.test.mjs
File metadata and controls
29 lines (24 loc) · 753 Bytes
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
// @ts-check
import { strictEqual, throws } from "node:assert";
import CliError from "./CliError.mjs";
/**
* Adds `CliError` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`CliError` with argument 1 `message` not a string.", () => {
throws(() => {
new CliError(
// @ts-expect-error Testing invalid.
true
);
}, new TypeError("Argument 1 `message` must be a string."));
});
tests.add("`CliError` with arguments valid.", () => {
const message = "Message.";
const error = new CliError(message);
strictEqual(error instanceof Error, true);
strictEqual(error.name, "CliError");
strictEqual(error.message, message);
});
};