openpanel/packages/graphql/test/create/index.spec.ts
Stefan Pejcic 8595a9f4e5 back
2024-05-08 19:58:53 +02:00

49 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).create({
resource: "posts",
variables: {
title: "foo",
content: "bar",
category: "2",
},
meta: {
fields: [
{
operation: "post",
fields: [
"id",
"title",
"content",
{ category: ["id"] },
],
variables: {},
},
],
},
});
expect(data["id"]).toEqual("43");
expect(data["title"]).toEqual("foo");
expect(data["content"]).toEqual("bar");
expect(data["category"].id).toEqual("2");
});
it("correct response without meta", async () => {
const { data } = await dataProvider(client).create({
resource: "posts",
variables: {
title: "foo",
content: "bar",
category: "2",
},
});
expect(data["id"]).toEqual("44");
});
});