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,76 @@
import nock from "nock";
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
.post("/graphql", {
query: "mutation ($input: createPostInput) {\n createPost (input: $input) {\n post { id, title, content, category { id } }\n }\n }",
variables: {
input: { data: { title: "foo", content: "bar", category: "2" } },
},
})
.reply(
200,
{
data: {
createPost: {
post: {
id: "43",
title: "foo",
content: "bar",
category: { id: "2" },
},
},
},
},
[
"Server",
"nginx/1.17.10",
"Date",
"Thu, 16 Sep 2021 13:28:08 GMT",
"Content-Type",
"application/json",
"Content-Length",
"97",
"Connection",
"close",
"Vary",
"Origin",
"Strict-Transport-Security",
"max-age=31536000; includeSubDomains",
"X-Frame-Options",
"SAMEORIGIN",
"X-Powered-By",
"Strapi <strapi.io>",
"X-Response-Time",
"39ms",
],
);
nock("https://api.strapi.refine.dev:443", { encodedQueryParams: true })
.post("/graphql", {
query: "mutation ($input: createPostInput) {\n createPost (input: $input) {\n post { id }\n }\n }",
variables: {
input: { data: { title: "foo", content: "bar", category: "2" } },
},
})
.reply(200, { data: { createPost: { post: { id: "44" } } } }, [
"Server",
"nginx/1.17.10",
"Date",
"Thu, 16 Sep 2021 13:30:33 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",
"295ms",
]);

View File

@@ -0,0 +1,48 @@
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");
});
});