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

+13 -13
View File
@@ -5,7 +5,7 @@ import prisma from "@calcom/prisma";
describe("DELETE /api/api-keys/[id]/delete with valid id as string returns an apiKey", () => {
it("returns a message with the specified apiKeys", async () => {
const apiKey = await prisma.apiKey.findFirst()
const apiKey = await prisma.apiKey.findFirst();
const { req, res } = createMocks({
method: "DELETE",
query: {
@@ -15,7 +15,9 @@ describe("DELETE /api/api-keys/[id]/delete with valid id as string returns an ap
// const apiKey = await prisma.apiKey.findUnique({ where: { id: req.query.id} });
await handleDeleteApiKey(req, res);
expect(res._getStatusCode()).toBe(204);
expect(JSON.parse(res._getData())).toEqual({message: `api-key with id: ${apiKey?.id} deleted successfully`});
expect(JSON.parse(res._getData())).toEqual({
message: `api-key with id: ${apiKey?.id} deleted successfully`,
});
});
});
@@ -56,15 +58,15 @@ describe("DELETE /api/api-keys/[id]/delete an id not present in db like 0, throw
expect(res._getStatusCode()).toBe(404);
expect(JSON.parse(res._getData())).toStrictEqual({
"error": {
"clientVersion": "3.10.0",
"code": "P2025",
"meta": {
"cause": "Record to delete does not exist.",
},
},
"message": "Resource with id:0 was not found",
});
error: {
clientVersion: "3.10.0",
code: "P2025",
meta: {
cause: "Record to delete does not exist.",
},
},
message: "Resource with id:0 was not found",
});
});
});
@@ -82,5 +84,3 @@ describe("POST /api/api-keys/[id]/delete fails, only DELETE allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only DELETE Method allowed" });
});
});
+29 -15
View File
@@ -2,7 +2,8 @@ import handleapiKeyEdit from "@api/api-keys/[id]/edit";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import {stringifyISODate} from "@lib/utils/stringifyISODate";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("PATCH /api/api-keys/[id]/edit with valid id and body with note", () => {
it("returns a 200 and the updated apiKey note", async () => {
@@ -19,7 +20,13 @@ describe("PATCH /api/api-keys/[id]/edit with valid id and body with note", () =>
await handleapiKeyEdit(req, res);
expect(res._getStatusCode()).toBe(200);
expect(JSON.parse(res._getData())).toEqual({ data: {...apiKey, createdAt: stringifyISODate(apiKey?.createdAt), expiresAt: stringifyISODate(apiKey?.expiresAt)} });
expect(JSON.parse(res._getData())).toEqual({
data: {
...apiKey,
createdAt: stringifyISODate(apiKey?.createdAt),
expiresAt: stringifyISODate(apiKey?.expiresAt),
},
});
});
});
@@ -39,20 +46,22 @@ describe("PATCH /api/api-keys/[id]/edit with invalid id returns 404", () => {
expect(res._getStatusCode()).toBe(404);
if (apiKey) apiKey.note = "Updated note";
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": "apiKey with ID cl16zg6860000wwylnsgva00a not found and wasn't updated", });
message: "apiKey with ID cl16zg6860000wwylnsgva00a not found and wasn't updated",
});
});
});
describe("PATCH /api/api-keys/[id]/edit with valid id and no body returns 200 with an apiKey with no note and default expireAt", () => {
it("returns a message with the specified apiKeys", async () => {
const apiKey = await prisma.apiKey.create({data:{} });
const apiKey = await prisma.apiKey.create({ data: {} });
const { req, res } = createMocks({
method: "PATCH",
query: {
@@ -63,8 +72,13 @@ describe("PATCH /api/api-keys/[id]/edit with valid id and no body returns 200 wi
expect(apiKey?.note).toBeNull();
expect(res._getStatusCode()).toBe(200);
expect(JSON.parse(res._getData())).toEqual({ data: {...apiKey, createdAt: stringifyISODate(apiKey?.createdAt), expiresAt: stringifyISODate(apiKey?.expiresAt)} });
expect(JSON.parse(res._getData())).toEqual({
data: {
...apiKey,
createdAt: stringifyISODate(apiKey?.createdAt),
expiresAt: stringifyISODate(apiKey?.expiresAt),
},
});
});
});
@@ -82,8 +96,8 @@ describe("POST /api/api-keys/[id]/edit fails, only PATCH allowed", () => {
await handleapiKeyEdit(req, res);
expect(res._getStatusCode()).toBe(405);
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only PATCH Method allowed for updating API keys" });
expect(JSON.parse(res._getData())).toStrictEqual({
message: "Only PATCH Method allowed for updating API keys",
});
});
});
+10 -5
View File
@@ -2,7 +2,8 @@ import handleApiKey from "@api/api-keys/[id]";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import {stringifyISODate} from "@lib/utils/stringifyISODate";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("GET /api/api-keys/[id] with valid id as string returns an apiKey", () => {
it("returns a message with the specified apiKeys", async () => {
@@ -12,11 +13,17 @@ describe("GET /api/api-keys/[id] with valid id as string returns an apiKey", ()
id: "cl16zg6860000wwylnsgva00b",
},
});
const apiKey = await prisma.apiKey.findUnique({ where: { id: req.query.id} });
const apiKey = await prisma.apiKey.findUnique({ where: { id: req.query.id } });
await handleApiKey(req, res);
expect(res._getStatusCode()).toBe(200);
expect(JSON.parse(res._getData())).toEqual({ data: {...apiKey, createdAt: stringifyISODate(apiKey?.createdAt), expiresAt: stringifyISODate(apiKey?.expiresAt)} });
expect(JSON.parse(res._getData())).toEqual({
data: {
...apiKey,
createdAt: stringifyISODate(apiKey?.createdAt),
expiresAt: stringifyISODate(apiKey?.expiresAt),
},
});
});
});
@@ -74,5 +81,3 @@ describe("POST /api/api-keys/[id] fails, only GET allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only GET Method allowed" });
});
});
+11 -3
View File
@@ -2,7 +2,8 @@ import handleApiKeys from "@api/api-keys";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import {stringifyISODate} from "@lib/utils/stringifyISODate";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("GET /api/api-keys without any params", () => {
it("returns a message with the specified apiKeys", async () => {
@@ -14,8 +15,15 @@ describe("GET /api/api-keys without any params", () => {
await handleApiKeys(req, res);
expect(res._getStatusCode()).toBe(200);
apiKeys = apiKeys.map(apiKey => (apiKey = {...apiKey, createdAt: stringifyISODate(apiKey?.createdAt), expiresAt: stringifyISODate(apiKey?.expiresAt)}));
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: {...apiKeys} })));
apiKeys = apiKeys.map(
(apiKey) =>
(apiKey = {
...apiKey,
createdAt: stringifyISODate(apiKey?.createdAt),
expiresAt: stringifyISODate(apiKey?.expiresAt),
})
);
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: { ...apiKeys } })));
});
});
+18 -12
View File
@@ -28,13 +28,17 @@ describe("POST /api/api-keys/new with a slug param", () => {
await handleNewApiKey(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual(
[{"code": "unrecognized_keys", "keys": ["slug"], "message": "Unrecognized key(s) in object: 'slug'", "path": []}]
);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "unrecognized_keys",
keys: ["slug"],
message: "Unrecognized key(s) in object: 'slug'",
path: [],
},
]);
});
});
describe("GET /api/api-keys/new fails, only POST allowed", () => {
it("returns a message with the specified apiKeys", async () => {
const { req, res } = createMocks({
@@ -47,14 +51,13 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
});
});
// FIXME: test 405 when prisma fails look for how to test prisma errors
describe("GET /api/api-keys/new fails, only POST allowed", () => {
it("returns a message with the specified apiKeys", async () => {
const { req, res } = createMocks({
method: "POST", // This POST method is not allowed
body: {
nonExistentParam: true
nonExistentParam: true,
// note: '123',
// slug: 12,
},
@@ -62,10 +65,13 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
await handleNewApiKey(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual([{
"code": "unrecognized_keys",
"keys": ["nonExistentParam"],
"message": "Unrecognized key(s) in object: 'nonExistentParam'", "path": []
}]);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "unrecognized_keys",
keys: ["nonExistentParam"],
message: "Unrecognized key(s) in object: 'nonExistentParam'",
path: [],
},
]);
});
});
});
+35 -11
View File
@@ -43,14 +43,16 @@ describe("PATCH /api/bookings/[id]/edit with invalid id returns 404", () => {
expect(res._getStatusCode()).toBe(404);
if (booking) booking.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/bookings/[id]/edit with valid id and no body returns 400 er
await handleBookingEdit(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/bookings/[id]/edit fails, only PATCH allowed", () => {
await handleBookingEdit(req, res);
expect(res._getStatusCode()).toBe(405);
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only PATCH Method allowed for updating bookings" });
expect(JSON.parse(res._getData())).toStrictEqual({
message: "Only PATCH Method allowed for updating bookings",
});
});
});
+3 -4
View File
@@ -2,6 +2,7 @@ import handleBooking from "@api/bookings/[id]";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("GET /api/bookings/[id] with valid id as string returns an booking", () => {
@@ -21,8 +22,8 @@ describe("GET /api/bookings/[id] with valid id as string returns an booking", ()
...booking,
createdAt: stringifyISODate(booking?.createdAt),
startTime: stringifyISODate(booking?.startTime),
endTime: stringifyISODate(booking?.endTime)
}
endTime: stringifyISODate(booking?.endTime),
},
});
});
});
@@ -81,5 +82,3 @@ describe("POST /api/bookings/[id] fails, only GET allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only GET Method allowed" });
});
});
+11 -3
View File
@@ -2,7 +2,8 @@ import handleApiKeys from "@api/api-keys";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
import {stringifyISODate} from "@lib/utils/stringifyISODate";
import { stringifyISODate } from "@lib/utils/stringifyISODate";
describe("GET /api/api-keys without any params", () => {
it("returns a message with the specified apiKeys", async () => {
@@ -14,8 +15,15 @@ describe("GET /api/api-keys without any params", () => {
await handleApiKeys(req, res);
expect(res._getStatusCode()).toBe(200);
apiKeys = apiKeys.map(apiKey => (apiKey = {...apiKey, createdAt: stringifyISODate(apiKey?.createdAt), expiresAt: stringifyISODate(apiKey?.expiresAt)}));
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: {...apiKeys} })));
apiKeys = apiKeys.map(
(apiKey) =>
(apiKey = {
...apiKey,
createdAt: stringifyISODate(apiKey?.createdAt),
expiresAt: stringifyISODate(apiKey?.expiresAt),
})
);
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: { ...apiKeys } })));
});
});
+18 -12
View File
@@ -28,13 +28,17 @@ describe("POST /api/api-keys/new with a slug param", () => {
await handleNewApiKey(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual(
[{"code": "unrecognized_keys", "keys": ["slug"], "message": "Unrecognized key(s) in object: 'slug'", "path": []}]
);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "unrecognized_keys",
keys: ["slug"],
message: "Unrecognized key(s) in object: 'slug'",
path: [],
},
]);
});
});
describe("GET /api/api-keys/new fails, only POST allowed", () => {
it("returns a message with the specified apiKeys", async () => {
const { req, res } = createMocks({
@@ -47,14 +51,13 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
});
});
// FIXME: test 405 when prisma fails look for how to test prisma errors
describe("GET /api/api-keys/new fails, only POST allowed", () => {
it("returns a message with the specified apiKeys", async () => {
const { req, res } = createMocks({
method: "POST", // This POST method is not allowed
body: {
nonExistentParam: true
nonExistentParam: true,
// note: '123',
// slug: 12,
},
@@ -62,10 +65,13 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
await handleNewApiKey(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual([{
"code": "unrecognized_keys",
"keys": ["nonExistentParam"],
"message": "Unrecognized key(s) in object: 'nonExistentParam'", "path": []
}]);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "unrecognized_keys",
keys: ["nonExistentParam"],
message: "Unrecognized key(s) in object: 'nonExistentParam'",
path: [],
},
]);
});
});
});
@@ -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",
});
});
});
@@ -73,5 +73,3 @@ describe("POST /api/event-types/[id] fails, only GET allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only GET Method allowed" });
});
});
+2 -1
View File
@@ -2,6 +2,7 @@ import handleApiKeys from "@api/event-types";
import { createMocks } from "node-mocks-http";
import prisma from "@calcom/prisma";
// import {stringifyISODate} from "@lib/utils/stringifyISODate";
describe("GET /api/event-types without any params", () => {
@@ -15,7 +16,7 @@ describe("GET /api/event-types without any params", () => {
expect(res._getStatusCode()).toBe(200);
// eventTypes = eventTypes.map(eventType => (eventType = {...eventType, createdAt: stringifyISODate(eventType?.createdAt), expiresAt: stringifyISODate(eventType?.expiresAt)}));
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: {...eventTypes} })));
expect(JSON.parse(res._getData())).toStrictEqual(JSON.parse(JSON.stringify({ data: { ...eventTypes } })));
});
});
+9 -7
View File
@@ -16,7 +16,6 @@ describe("POST /api/api-keys/new with a note", () => {
});
});
describe("POST /api/api-keys/new with a slug param", () => {
it("returns error 400, and the details about invalid slug body param", async () => {
const { req, res } = createMocks({
@@ -29,13 +28,17 @@ describe("POST /api/api-keys/new with a slug param", () => {
await handleNewApiKey(req, res);
expect(res._getStatusCode()).toBe(400);
expect(JSON.parse(res._getData())).toStrictEqual(
[{"code": "unrecognized_keys", "keys": ["slug"], "message": "Unrecognized key(s) in object: 'slug'", "path": []}]
);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "unrecognized_keys",
keys: ["slug"],
message: "Unrecognized key(s) in object: 'slug'",
path: [],
},
]);
});
});
describe("GET /api/api-keys/new fails, only POST allowed", () => {
it("returns a message with the specified apiKeys", async () => {
const { req, res } = createMocks({
@@ -48,7 +51,6 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
});
});
// FIXME: test 405 when prisma fails look for how to test prisma errors
// describe("GET /api/api-keys/new fails, only POST allowed", () => {
// it("returns a message with the specified apiKeys", async () => {
@@ -65,4 +67,4 @@ describe("GET /api/api-keys/new fails, only POST allowed", () => {
// expect(res._getStatusCode()).toBe(400);
// expect(JSON.parse(res._getData())).toStrictEqual({ error: "Only POST Method allowed" });
// });
// });
// });
+28 -11
View File
@@ -40,14 +40,16 @@ describe("PATCH /api/teams/[id]/edit with invalid id returns 404", () => {
await handleTeamEdit(req, res);
expect(res._getStatusCode()).toBe(404);
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",
});
});
});
@@ -64,7 +66,22 @@ describe("PATCH /api/teams/[id]/edit with valid id and no body returns 400 error
expect(res._getStatusCode()).toBe(400);
// Ugly parsing of zod validation errors, not for final production but works for testing
expect(JSON.parse(res._getData())).toStrictEqual([{"code": "invalid_type", "expected": "string", "message": "Required", "path": ["slug"], "received": "undefined"}, {"code": "invalid_type", "expected": "string", "message": "Required", "path": ["name"], "received": "undefined"}]);
expect(JSON.parse(res._getData())).toStrictEqual([
{
code: "invalid_type",
expected: "string",
message: "Required",
path: ["slug"],
received: "undefined",
},
{
code: "invalid_type",
expected: "string",
message: "Required",
path: ["name"],
received: "undefined",
},
]);
});
});
@@ -83,8 +100,8 @@ describe("POST /api/teams/[id]/edit fails, only PATCH allowed", () => {
await handleTeamEdit(req, res);
expect(res._getStatusCode()).toBe(405);
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only PATCH Method allowed for updating teams" });
expect(JSON.parse(res._getData())).toStrictEqual({
message: "Only PATCH Method allowed for updating teams",
});
});
});
-2
View File
@@ -73,5 +73,3 @@ describe("POST /api/teams/[id] fails, only GET allowed", () => {
expect(JSON.parse(res._getData())).toStrictEqual({ message: "Only GET Method allowed" });
});
});
+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" });
});
});