Attempting to fix types
parent
287c455a52
commit
b52c2c3d07
|
@ -6,6 +6,7 @@ import { createMocks } from "node-mocks-http";
|
||||||
import { afterAll, describe, expect, test, vi } from "vitest";
|
import { afterAll, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
import { symmetricEncrypt } from "@calcom/lib/crypto";
|
import { symmetricEncrypt } from "@calcom/lib/crypto";
|
||||||
|
import { buildApp, buildUser } from "@calcom/lib/test/builder";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
import handler from "../../../../pages/api/webhook/app-credential";
|
import handler from "../../../../pages/api/webhook/app-credential";
|
||||||
|
@ -47,19 +48,22 @@ describe("app-credential webhook", () => {
|
||||||
prisma,
|
prisma,
|
||||||
});
|
});
|
||||||
|
|
||||||
prismaMock.user.findUnique.mockResolvedValue({ id: 1 });
|
prismaMock.user.findUnique.mockResolvedValue(
|
||||||
prismaMock.app.findUnique.mockResolvedValue({
|
buildUser({
|
||||||
|
id: 1,
|
||||||
|
username: "test",
|
||||||
|
name: "Test User",
|
||||||
|
email: "test@example.com",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
prismaMock.app.findUnique.mockResolvedValue(
|
||||||
|
buildApp({
|
||||||
slug: "office365-calendar",
|
slug: "office365-calendar",
|
||||||
dirName: "office365calendar",
|
dirName: "office365calendar",
|
||||||
keys: "test-keys",
|
keys: "test-keys",
|
||||||
});
|
})
|
||||||
|
);
|
||||||
prismaMock.credential.create.mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
await handler(req, res);
|
await handler(req, res);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import type { Booking, EventType, Prisma, Webhook } from "@prisma/client";
|
import type { App, Booking, EventType, Prisma, Webhook } from "@prisma/client";
|
||||||
import type { TFunction } from "next-i18next";
|
import type { TFunction } from "next-i18next";
|
||||||
|
|
||||||
import { BookingStatus } from "@calcom/prisma/enums";
|
import { BookingStatus } from "@calcom/prisma/enums";
|
||||||
|
@ -227,3 +227,17 @@ export const buildUser = <T extends Partial<UserPayload>>(user?: T): UserPayload
|
||||||
...user,
|
...user,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const buildApp = (app?: Partial<App>): App => {
|
||||||
|
return {
|
||||||
|
categories: null,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
credentials: null,
|
||||||
|
payments: null,
|
||||||
|
Webhook: null,
|
||||||
|
ApiKey: null,
|
||||||
|
enabled: true,
|
||||||
|
...app,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue