-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcheckGraphQLValidationRules.test.mjs
56 lines (50 loc) · 1.34 KB
/
checkGraphQLValidationRules.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
46
47
48
49
50
51
52
53
54
55
56
// @ts-check
import { doesNotThrow, throws } from "node:assert";
import { specifiedRules } from "graphql";
import checkGraphQLValidationRules from "./checkGraphQLValidationRules.mjs";
/**
* Adds `checkGraphQLValidationRules` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add(
"`checkGraphQLValidationRules` with valid GraphQL validation rules.",
() => {
doesNotThrow(() => checkGraphQLValidationRules(specifiedRules, "Test"));
}
);
tests.add("`checkGraphQLValidationRules` with a non array.", () => {
throws(
() =>
checkGraphQLValidationRules(
// @ts-expect-error Testing invalid.
false,
"Test"
),
{
name: "InternalServerError",
message: "Test GraphQL validation rules must be an array.",
status: 500,
expose: false,
}
);
});
tests.add("`checkGraphQLValidationRules` with non function rules.", () => {
throws(
() =>
checkGraphQLValidationRules(
[
// @ts-expect-error Testing invalid.
false,
],
"Test"
),
{
name: "InternalServerError",
message: "Test GraphQL validation rules must be functions.",
status: 500,
expose: false,
}
);
});
};