This commit is contained in:
Agusti Fernandez Pardo committed 2022-03-30 14:17:55 +02:00
1 parent 39ae2aed37
commit 1de7bc4146
126 files changed
+1240 -992

No files matched your search

+35 -11
View File
@@ -43,14 +43,16 @@ describe("PATCH /api/event-types/[id]/edit with invalid id returns 404", () => {
expect(res._getStatusCode()).toBe(404);
if (event) event.title = "Updated title";
expect(JSON.parse(res._getData())).toStrictEqual({ "error": {
"clientVersion": "3.10.0",
"code": "P2025",
"meta": {
"cause": "Record to update not found.",
},
expect(JSON.parse(res._getData())).toStrictEqual({
error: {
clientVersion: "3.10.0",
code: "P2025",
meta: {
cause: "Record to update not found.",
},
},
"message": "Event type with ID 0 not found and wasn't updated", });
message: "Event type with ID 0 not found and wasn't updated",
});
});
});
@@ -65,7 +67,29 @@ describe("PATCH /api/event-types/[id]/edit with valid id and no body returns 400
await handleEventTypeEdit(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual([{"code": "invalid_type", "expected": "string", "message": "Required", "path": ["title"], "received": "undefined"}, {"code": "invalid_type", "expected": "string", "message": "Required", "path": ["slug"], "received": "undefined"}, {"code": "invalid_type", "expected": "number", "message": "Required", "path": ["length"], "received": "undefined"}]);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "invalid_type",
expected: "string",
message: "Required",
path: ["title"],
received: "undefined",
},
{
code: "invalid_type",
expected: "string",
message: "Required",
path: ["slug"],
received: "undefined",
},
{
code: "invalid_type",
expected: "number",
message: "Required",
path: ["length"],
received: "undefined",
},
]);
});
});
@@ -85,8 +109,8 @@ describe("POST /api/event-types/[id]/edit fails, only PATCH allowed", () => {
await handleEventTypeEdit(req, res);
expect(res._getStatusCode()).toBe(405);
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only PATCH Method allowed for updating event-types" });
expect(JSON.parse(res._getData())).toStrictEqual({
message: "Only PATCH Method allowed for updating event-types",
});
});
});
+8 -3
View File
@@ -2,6 +2,7 @@ import handleUser from "@api/users/[id]";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("GET /api/users/[id] with valid id as string returns an user-type", () => {
@@ -16,7 +17,13 @@ describe("GET /api/users/[id] with valid id as string returns an user-type", ()
await handleUser(req, res);
expect(res._getStatusCode()).toBe(200);
expect(JSON.parse(res._getData())).toEqual({ data: {...user, createdDate: stringifyISODate(user?.createdDate), emailVerified: stringifyISODate(user?.emailVerified)} });
expect(JSON.parse(res._getData())).toEqual({
data: {
...user,
createdDate: stringifyISODate(user?.createdDate),
emailVerified: stringifyISODate(user?.emailVerified),
},
});
});
});
@@ -74,5 +81,3 @@ describe("POST /api/users/[id] fails, only GET allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only GET Method allowed" });
});
});