-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcheckOptions.test.mjs
40 lines (35 loc) · 983 Bytes
/
checkOptions.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
// @ts-check
import { doesNotThrow, throws } from "node:assert";
import checkOptions from "./checkOptions.mjs";
/**
* Adds `checkOptions` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`checkOptions` with valid options.", () => {
doesNotThrow(() => checkOptions({ a: true }, ["a"], "Test"));
});
tests.add("`checkOptions` with unenumerable options.", () => {
throws(
() =>
checkOptions(
// @ts-expect-error Testing invalid.
null,
["a"],
"Test"
),
{
message: "Test options must be an enumerable object.",
status: 500,
expose: false,
}
);
});
tests.add("`checkOptions` with invalid option keys.", () => {
throws(() => checkOptions({ a: true, b: true, c: true }, ["b"], "Test"), {
message: "Test options invalid: `a`, `c`.",
status: 500,
expose: false,
});
});
};