File tree Expand file tree Collapse file tree 6 files changed +54
-23
lines changed
features/user-database-credentials Expand file tree Collapse file tree 6 files changed +54
-23
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Better Authを使った認証とPer-User DBクレデンシャル管理を担う
1616| ` ./user-database-credentials ` | Per-User DBクレデンシャルのCRUD、有効なクレデンシャル取得(期限切れ時自動更新) |
1717| ` ./integrations/better-auth-nextjs ` | Next.js向けBetter Auth統合 |
1818| ` ./integrations/better-auth-react ` | React/Expo向けBetter Auth統合 |
19+ | ` ./testing ` | テスト用モック関数(saveUserDatabaseCredentials, getValidCredentials) |
1920
2021## データベーススキーマ
2122
Original file line number Diff line number Diff line change 77 "./create-auth" : " ./src/features/instance/create-auth.ts" ,
88 "./user-database-credentials" : " ./src/features/user-database-credentials/index.ts" ,
99 "./integrations/better-auth-nextjs" : " ./src/features/integrations/better-auth-nextjs.ts" ,
10- "./integrations/better-auth-react" : " ./src/features/integrations/better-auth-react.ts"
10+ "./integrations/better-auth-react" : " ./src/features/integrations/better-auth-react.ts" ,
11+ "./testing" : " ./src/testing/index.ts"
1112 },
1213 "scripts" : {
1314 "lint" : " biome check ." ,
Original file line number Diff line number Diff line change 1+ import { R } from "@praha/byethrow" ;
2+ import { vi } from "vitest" ;
3+ import type { GetValidCredentialsError } from "./get-valid-credentials" ;
4+ import * as module from "./get-valid-credentials" ;
5+
6+ export const mockGetValidCredentialsOk = (
7+ overrides ?: Partial < R . InferSuccess < typeof module . getValidCredentials > > ,
8+ ) => {
9+ return vi . spyOn ( module , "getValidCredentials" ) . mockResolvedValue (
10+ R . succeed ( {
11+ dbName : "mock-per-user-db-name" ,
12+ url : "libsql://mock-per-user-db.turso.io" ,
13+ token : "mock-valid-token" ,
14+ expiresAt : new Date ( "2026-12-31T00:00:00.000Z" ) ,
15+ ...overrides ,
16+ } ) ,
17+ ) ;
18+ } ;
19+
20+ export const mockGetValidCredentialsError = (
21+ error : GetValidCredentialsError ,
22+ ) => {
23+ return vi
24+ . spyOn ( module , "getValidCredentials" )
25+ . mockResolvedValue ( R . fail ( error ) ) ;
26+ } ;
Original file line number Diff line number Diff line change 1+ import { R } from "@praha/byethrow" ;
2+ import { vi } from "vitest" ;
3+ import * as module from "./save-user-database-credentials" ;
4+
5+ export const mockSaveUserDatabaseCredentialsOk = ( ) => {
6+ return vi
7+ . spyOn ( module , "saveUserDatabaseCredentials" )
8+ . mockResolvedValue ( R . succeed ( undefined ) ) ;
9+ } ;
10+
11+ export const mockSaveUserDatabaseCredentialsError = (
12+ error : module . SaveUserDatabaseCredentialsError | module . EncryptTokenError ,
13+ ) => {
14+ return vi
15+ . spyOn ( module , "saveUserDatabaseCredentials" )
16+ . mockResolvedValue ( R . fail ( error ) ) ;
17+ } ;
Original file line number Diff line number Diff line change 1+ export {
2+ mockGetValidCredentialsError ,
3+ mockGetValidCredentialsOk ,
4+ } from "../features/user-database-credentials/get-valid-credentials.mock.js" ;
5+ export {
6+ mockSaveUserDatabaseCredentialsError ,
7+ mockSaveUserDatabaseCredentialsOk ,
8+ } from "../features/user-database-credentials/save-user-database-credentials.mock.js" ;
You can’t perform that action at this time.
0 commit comments