-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
index.spec.ts
52 lines (48 loc) · 1.61 KB
/
index.spec.ts
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
import dataProvider from "../../src/index";
import client from "../gqlClient";
import "./index.mock";
describe("custom", () => {
it("correct get query response", async () => {
const response = await dataProvider(client).custom?.({
url: "",
method: "get",
metaData: {
operation: "posts",
variables: {
sort: "id:asc",
where: { value: { title_contains: "foo" }, type: "JSON" },
},
fields: ["id", "title", { category: ["id"] }],
},
});
expect(response?.data[0].id).toBe("21");
expect(response?.data[0].title).toBe("updated-foo-2");
});
it("correct get mutation response", async () => {
const response = await dataProvider(client).custom?.({
url: "",
method: "post",
metaData: {
operation: "updatePost",
variables: {
input: {
value: {
where: { id: "32" },
data: { title: "custom-foo" },
},
type: "updatePostInput",
},
},
fields: [
{
operation: "post",
fields: ["id", "title"],
variables: {},
},
],
},
});
expect(response?.data.post.id).toBe("32");
expect(response?.data.post.title).toBe("custom-foo");
});
});