fork refine

This commit is contained in:
Stefan Pejcic
2024-02-05 10:23:04 +01:00
parent 3fffde9a8f
commit 8496a83edb
3634 changed files with 715528 additions and 2 deletions

View 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",
]);

View 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");
});
});