openpanel/packages/graphql/test/update/index.spec.ts
2024-02-05 10:23:04 +01:00

50 lines
1.4 KiB
TypeScript

import dataProvider from "../../src/index";
import client from "../gqlClient";
import "./index.mock";
describe("create", () => {
it("correct response with meta", async () => {
const { data } = await dataProvider(client).update({
resource: "posts",
id: "21",
variables: {
title: "updated-foo",
content: "updated-bar",
category: "2",
},
meta: {
fields: [
{
operation: "post",
fields: [
"id",
"title",
"content",
{ category: ["id"] },
],
variables: {},
},
],
},
});
expect(data["title"]).toEqual("updated-foo");
expect(data["content"]).toEqual("updated-bar");
expect(data["category"].id).toEqual("2");
});
it("correct response without meta", async () => {
const { data } = await dataProvider(client).update({
resource: "posts",
id: "21",
variables: {
title: "updated-foo-2",
content: "updated-bar-2",
category: "3",
},
});
expect(data["id"]).toEqual("21");
});
});