-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphQLUpload.test.mjs
61 lines (55 loc) · 1.38 KB
/
GraphQLUpload.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
57
58
59
60
61
// @ts-check
import { parseValue } from "graphql";
import { doesNotThrow, throws } from "node:assert";
import GraphQLUpload from "./GraphQLUpload.mjs";
import Upload from "./Upload.mjs";
/**
* Adds `GraphQLUpload` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`GraphQLUpload` scalar `parseValue` with a valid value.", () => {
doesNotThrow(() => {
GraphQLUpload.parseValue(new Upload());
});
});
tests.add(
"`GraphQLUpload` scalar `parseValue` with an invalid value.",
() => {
throws(
() => {
GraphQLUpload.parseValue(true);
},
{
name: "GraphQLError",
message: "Upload value invalid.",
}
);
}
);
tests.add("`GraphQLUpload` scalar `parseLiteral`.", () => {
throws(
() => {
// The dummy value is irrelevant.
GraphQLUpload.parseLiteral(parseValue('""'));
},
{
name: "GraphQLError",
message: "Upload literal unsupported.",
locations: [{ line: 1, column: 1 }],
}
);
});
tests.add("`GraphQLUpload` scalar `serialize`.", () => {
throws(
() => {
// The dummy value is irrelevant.
GraphQLUpload.serialize("");
},
{
name: "GraphQLError",
message: "Upload serialization unsupported.",
}
);
});
};