forked from usesend/useSend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.unit.test.ts
More file actions
52 lines (42 loc) · 1.09 KB
/
auth.unit.test.ts
File metadata and controls
52 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { describe, expect, it, vi } from "vitest";
vi.mock("next-auth", () => ({
getServerSession: vi.fn(),
}));
vi.mock("@auth/prisma-adapter", () => ({
PrismaAdapter: vi.fn(() => ({})),
}));
vi.mock("next-auth/providers/google", () => ({
default: vi.fn(),
}));
vi.mock("next-auth/providers/email", () => ({
default: vi.fn(),
}));
vi.mock("~/server/db", () => ({
db: {},
}));
vi.mock("~/server/mailer", () => ({
sendSignUpEmail: vi.fn(),
}));
vi.mock("~/env", () => ({
env: {
GITHUB_ID: "github-client-id",
GITHUB_SECRET: "github-client-secret",
NEXT_PUBLIC_IS_CLOUD: true,
},
}));
import { authOptions } from "~/server/auth";
describe("authOptions", () => {
it("configures the GitHub provider with an explicit issuer", () => {
const githubProvider = authOptions.providers.find(
(provider) => provider.id === "github",
);
expect(githubProvider).toMatchObject({
id: "github",
options: {
clientId: "github-client-id",
clientSecret: "github-client-secret",
issuer: "https://github.com/login/oauth",
},
});
});
});