85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import { WorkflowRepository } from "./workflow";
|
|
|
|
describe("WorkflowRepository", () => {
|
|
describe("getVerifiedEmails", () => {
|
|
it("should return the email of the user", async () => {
|
|
prismaMock.secondaryEmail.findMany.mockResolvedValue([]);
|
|
prismaMock.verifiedEmail.findMany.mockResolvedValue([]);
|
|
|
|
const emails = await WorkflowRepository.getVerifiedEmails({
|
|
userEmail: "[email protected]",
|
|
userId: 1,
|
|
});
|
|
expect(emails).toEqual(["[email protected]"]);
|
|
});
|
|
|
|
it("should return the email of the user and verified secondary emails", async () => {
|
|
prismaMock.verifiedEmail.findMany.mockResolvedValue([]);
|
|
prismaMock.secondaryEmail.findMany.mockResolvedValue([
|
|
{
|
|
id: 101,
|
|
email: "[email protected]",
|
|
emailVerified: new Date(),
|
|
},
|
|
]);
|
|
|
|
const emails = await WorkflowRepository.getVerifiedEmails({
|
|
userEmail: "[email protected]",
|
|
userId: 1,
|
|
});
|
|
expect(emails).toEqual(["[email protected]", "[email protected]"]);
|
|
});
|
|
|
|
it("should return the email of the user and verified secondary emails from the team", async () => {
|
|
prismaMock.verifiedEmail.findMany.mockResolvedValue([]);
|
|
prismaMock.secondaryEmail.findMany.mockResolvedValue([
|
|
{
|
|
id: 101,
|
|
email: "[email protected]",
|
|
emailVerified: new Date(),
|
|
},
|
|
]);
|
|
|
|
prismaMock.user.findMany.mockResolvedValue([
|
|
{
|
|
id: 1,
|
|
email: "[email protected]",
|
|
},
|
|
{
|
|
id: 2,
|
|
email: "[email protected]",
|
|
secondaryEmails: [],
|
|
},
|
|
{
|
|
id: 3,
|
|
email: "[email protected]",
|
|
secondaryEmails: [
|
|
{
|
|
email: "[email protected]",
|
|
emailVerified: new Date(),
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
|
|
const emails = await WorkflowRepository.getVerifiedEmails({
|
|
userEmail: "[email protected]",
|
|
userId: 1,
|
|
teamId: 1,
|
|
});
|
|
expect(emails).toEqual([
|
|
"[email protected]",
|
|
"[email protected]",
|
|
"[email protected]",
|
|
"[email protected]",
|
|
"[email protected]",
|
|
]);
|
|
});
|
|
});
|
|
});
|