mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
40 lines
929 B
TypeScript
40 lines
929 B
TypeScript
import { gql } from "@urql/core";
|
|
|
|
import dataProvider from "../../src/index";
|
|
import client from "../gqlClient";
|
|
import "./deleteOne.mock";
|
|
|
|
const gqlMutation = gql`
|
|
mutation DeleteOneBlogPost($input: DeleteOneBlogPostInput!) {
|
|
deleteOneBlogPost(input: $input) {
|
|
id
|
|
title
|
|
}
|
|
}
|
|
`;
|
|
|
|
describe("deleteOne", () => {
|
|
describe("with correct params", () => {
|
|
it("works as expected", async () => {
|
|
const { data } = await dataProvider(client).deleteOne({
|
|
resource: "blogPosts",
|
|
id: "42",
|
|
meta: {
|
|
gqlMutation,
|
|
},
|
|
});
|
|
|
|
expect(data.id).toEqual(null);
|
|
expect(data.title).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe("without operation", () => {
|
|
it("throws error", async () => {
|
|
expect(
|
|
dataProvider(client).deleteOne({ resource: "blogPosts", id: 42 }),
|
|
).rejects.toEqual(new Error("Operation is required."));
|
|
});
|
|
});
|
|
});
|