mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
fork refine
This commit is contained in:
121
packages/graphql/test/deleteMany/index.mock.ts
Normal file
121
packages/graphql/test/deleteMany/index.mock.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import nock from "nock";
|
||||
|
||||
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
|
||||
.post("/graphql", {
|
||||
query: "mutation ($input: deletePostInput) {\n deletePost (input: $input) {\n post { id, title }\n }\n }",
|
||||
variables: { input: { where: { id: "37" } } },
|
||||
})
|
||||
.reply(
|
||||
200,
|
||||
{ data: { deletePost: { post: { id: "37", title: "Hello" } } } },
|
||||
[
|
||||
"Server",
|
||||
"nginx/1.17.10",
|
||||
"Date",
|
||||
"Fri, 17 Sep 2021 09:07:05 GMT",
|
||||
"Content-Type",
|
||||
"application/json",
|
||||
"Content-Length",
|
||||
"61",
|
||||
"Connection",
|
||||
"close",
|
||||
"Vary",
|
||||
"Origin",
|
||||
"Strict-Transport-Security",
|
||||
"max-age=31536000; includeSubDomains",
|
||||
"X-Frame-Options",
|
||||
"SAMEORIGIN",
|
||||
"X-Powered-By",
|
||||
"Strapi <strapi.io>",
|
||||
"X-Response-Time",
|
||||
"144ms",
|
||||
],
|
||||
);
|
||||
|
||||
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
|
||||
.post("/graphql", {
|
||||
query: "mutation ($input: deletePostInput) {\n deletePost (input: $input) {\n post { id, title }\n }\n }",
|
||||
variables: { input: { where: { id: "38" } } },
|
||||
})
|
||||
.reply(
|
||||
200,
|
||||
{ data: { deletePost: { post: { id: "38", title: "Loem" } } } },
|
||||
[
|
||||
"Server",
|
||||
"nginx/1.17.10",
|
||||
"Date",
|
||||
"Fri, 17 Sep 2021 09:07:05 GMT",
|
||||
"Content-Type",
|
||||
"application/json",
|
||||
"Content-Length",
|
||||
"60",
|
||||
"Connection",
|
||||
"close",
|
||||
"Vary",
|
||||
"Origin",
|
||||
"Strict-Transport-Security",
|
||||
"max-age=31536000; includeSubDomains",
|
||||
"X-Frame-Options",
|
||||
"SAMEORIGIN",
|
||||
"X-Powered-By",
|
||||
"Strapi <strapi.io>",
|
||||
"X-Response-Time",
|
||||
"129ms",
|
||||
],
|
||||
);
|
||||
|
||||
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
|
||||
.post("/graphql", {
|
||||
query: "mutation ($input: deletePostInput) {\n deletePost (input: $input) {\n post { id }\n }\n }",
|
||||
variables: { input: { where: { id: "34" } } },
|
||||
})
|
||||
.reply(200, { data: { deletePost: { post: { id: "34" } } } }, [
|
||||
"Server",
|
||||
"nginx/1.17.10",
|
||||
"Date",
|
||||
"Fri, 17 Sep 2021 09:08:27 GMT",
|
||||
"Content-Type",
|
||||
"application/json",
|
||||
"Content-Length",
|
||||
"45",
|
||||
"Connection",
|
||||
"close",
|
||||
"Vary",
|
||||
"Origin",
|
||||
"Strict-Transport-Security",
|
||||
"max-age=31536000; includeSubDomains",
|
||||
"X-Frame-Options",
|
||||
"SAMEORIGIN",
|
||||
"X-Powered-By",
|
||||
"Strapi <strapi.io>",
|
||||
"X-Response-Time",
|
||||
"137ms",
|
||||
]);
|
||||
|
||||
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
|
||||
.post("/graphql", {
|
||||
query: "mutation ($input: deletePostInput) {\n deletePost (input: $input) {\n post { id }\n }\n }",
|
||||
variables: { input: { where: { id: "35" } } },
|
||||
})
|
||||
.reply(200, { data: { deletePost: { post: { id: "35" } } } }, [
|
||||
"Server",
|
||||
"nginx/1.17.10",
|
||||
"Date",
|
||||
"Fri, 17 Sep 2021 09:08:27 GMT",
|
||||
"Content-Type",
|
||||
"application/json",
|
||||
"Content-Length",
|
||||
"45",
|
||||
"Connection",
|
||||
"close",
|
||||
"Vary",
|
||||
"Origin",
|
||||
"Strict-Transport-Security",
|
||||
"max-age=31536000; includeSubDomains",
|
||||
"X-Frame-Options",
|
||||
"SAMEORIGIN",
|
||||
"X-Powered-By",
|
||||
"Strapi <strapi.io>",
|
||||
"X-Response-Time",
|
||||
"129ms",
|
||||
]);
|
||||
38
packages/graphql/test/deleteMany/index.spec.ts
Normal file
38
packages/graphql/test/deleteMany/index.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import dataProvider from "../../src/index";
|
||||
import client from "../gqlClient";
|
||||
import "./index.mock";
|
||||
|
||||
describe("deleteMany", () => {
|
||||
it("correct response with meta", async () => {
|
||||
const { data } = await dataProvider(client).deleteMany!({
|
||||
resource: "posts",
|
||||
ids: ["37", "38"],
|
||||
meta: {
|
||||
fields: [
|
||||
{
|
||||
operation: "post",
|
||||
fields: ["id", "title"],
|
||||
variables: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(data[0].id).toEqual("37");
|
||||
expect(data[0].title).toEqual("Hello");
|
||||
|
||||
expect(data[1].id).toEqual("38");
|
||||
expect(data[1].title).toEqual("Loem");
|
||||
});
|
||||
|
||||
it("correct response without meta", async () => {
|
||||
const { data } = await dataProvider(client).deleteMany!({
|
||||
resource: "posts",
|
||||
ids: ["34", "35"],
|
||||
});
|
||||
|
||||
expect(data[0].id).toEqual("34");
|
||||
|
||||
expect(data[1].id).toEqual("35");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user