MCPcopy
hub / github.com/nextauthjs/next-auth / runBasicTests

Function runBasicTests

packages/adapter-test/index.ts:41–315  ·  view source on GitHub ↗
(options: TestOptions)

Source from the content-addressed store, hash-verified

39 * You can add additional tests below, if you wish.
40 */
41export function runBasicTests(options: TestOptions) {
42 const id = options.db.id ?? randomUUID
43 // Init
44 beforeAll(async () => {
45 await options.db.connect?.()
46 })
47
48 const { adapter, db } = options
49
50 afterAll(async () => {
51 // @ts-expect-error This is only used for the TypeORM adapter
52 await adapter.__disconnect?.()
53 await options.db.disconnect?.()
54 })
55
56 let user: any = {
57 email: "fill@murray.com",
58 image: "https://www.fillmurray.com/460/300",
59 name: "Fill Murray",
60 emailVerified: new Date(),
61 }
62
63 if (process.env.CUSTOM_MODEL === "1") {
64 user.role = "admin"
65 user.phone = "00000000000"
66 }
67
68 const session: any = {
69 sessionToken: randomUUID(),
70 expires: ONE_WEEK_FROM_NOW,
71 }
72
73 const account: any = {
74 provider: "github",
75 providerAccountId: randomUUID(),
76 type: "oauth",
77 access_token: randomUUID(),
78 expires_at: ONE_MONTH,
79 id_token: randomUUID(),
80 refresh_token: randomUUID(),
81 token_type: "bearer",
82 scope: "user",
83 session_state: randomUUID(),
84 }
85
86 // All adapters must define these methods
87
88 test("Required (User, Account, Session) methods exist", () => {
89 const requiredMethods = [
90 "createUser",
91 "getUser",
92 "getUserByEmail",
93 "getUserByAccount",
94 "updateUser",
95 "linkAccount",
96 "createSession",
97 "getSessionAndUser",
98 "updateSession",

Callers 15

index.test.tsFile · 0.90
custom.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
entities.test.tsFile · 0.90

Calls 2

idFunction · 0.85
hashTokenFunction · 0.70

Tested by

no test coverage detected