this repo has no description

test(api): made utils file for tests

+65 -3
+35
apps/api/tests/utils.ts
··· 1 + import { test, expect, beforeAll, afterAll, beforeEach, afterEach } from "bun:test"; 2 + import { setupTestDb, teardownTestDb } from "db/test-utils"; 3 + import type { InferOutput } from "@atcute/lexicons/validations"; 4 + import type { CaAnsxorCatnipTrack } from "lexicon/atcute-lexicon"; 5 + import router from "../index"; 6 + 7 + let db: Awaited<ReturnType<typeof setupTestDb>>; 8 + let txDb: typeof db; 9 + let rollback: () => void; 10 + 11 + beforeAll(async () => { 12 + db = await setupTestDb(); 13 + }); 14 + 15 + afterAll(async () => { 16 + await teardownTestDb(); 17 + }); 18 + 19 + beforeEach(async () => { 20 + await new Promise<void>((resolveSetup) => { 21 + let rejectTx: (err: Error) => void; 22 + db.transaction(async (tx) => { 23 + txDb = tx as unknown as typeof db; 24 + resolveSetup(); 25 + await new Promise<void>((_, reject) => { 26 + rejectTx = reject; 27 + }); 28 + }).catch(() => {}); 29 + rollback = () => rejectTx(new Error("rollback")); 30 + }); 31 + }); 32 + 33 + afterEach(() => { 34 + rollback(); 35 + });
+21 -3
apps/frontend/src/routeTree.gen.ts
··· 11 11 import { Route as rootRouteImport } from './routes/__root' 12 12 import { Route as AboutRouteImport } from './routes/about' 13 13 import { Route as IndexRouteImport } from './routes/index' 14 + import { Route as ProfileDidRouteImport } from './routes/profile/$did' 14 15 15 16 const AboutRoute = AboutRouteImport.update({ 16 17 id: '/about', ··· 20 21 const IndexRoute = IndexRouteImport.update({ 21 22 id: '/', 22 23 path: '/', 24 + getParentRoute: () => rootRouteImport, 25 + } as any) 26 + const ProfileDidRoute = ProfileDidRouteImport.update({ 27 + id: '/profile/$did', 28 + path: '/profile/$did', 23 29 getParentRoute: () => rootRouteImport, 24 30 } as any) 25 31 26 32 export interface FileRoutesByFullPath { 27 33 '/': typeof IndexRoute 28 34 '/about': typeof AboutRoute 35 + '/profile/$did': typeof ProfileDidRoute 29 36 } 30 37 export interface FileRoutesByTo { 31 38 '/': typeof IndexRoute 32 39 '/about': typeof AboutRoute 40 + '/profile/$did': typeof ProfileDidRoute 33 41 } 34 42 export interface FileRoutesById { 35 43 __root__: typeof rootRouteImport 36 44 '/': typeof IndexRoute 37 45 '/about': typeof AboutRoute 46 + '/profile/$did': typeof ProfileDidRoute 38 47 } 39 48 export interface FileRouteTypes { 40 49 fileRoutesByFullPath: FileRoutesByFullPath 41 - fullPaths: '/' | '/about' 50 + fullPaths: '/' | '/about' | '/profile/$did' 42 51 fileRoutesByTo: FileRoutesByTo 43 - to: '/' | '/about' 44 - id: '__root__' | '/' | '/about' 52 + to: '/' | '/about' | '/profile/$did' 53 + id: '__root__' | '/' | '/about' | '/profile/$did' 45 54 fileRoutesById: FileRoutesById 46 55 } 47 56 export interface RootRouteChildren { 48 57 IndexRoute: typeof IndexRoute 49 58 AboutRoute: typeof AboutRoute 59 + ProfileDidRoute: typeof ProfileDidRoute 50 60 } 51 61 52 62 declare module '@tanstack/react-router' { ··· 65 75 preLoaderRoute: typeof IndexRouteImport 66 76 parentRoute: typeof rootRouteImport 67 77 } 78 + '/profile/$did': { 79 + id: '/profile/$did' 80 + path: '/profile/$did' 81 + fullPath: '/profile/$did' 82 + preLoaderRoute: typeof ProfileDidRouteImport 83 + parentRoute: typeof rootRouteImport 84 + } 68 85 } 69 86 } 70 87 71 88 const rootRouteChildren: RootRouteChildren = { 72 89 IndexRoute: IndexRoute, 73 90 AboutRoute: AboutRoute, 91 + ProfileDidRoute: ProfileDidRoute, 74 92 } 75 93 export const routeTree = rootRouteImport 76 94 ._addFileChildren(rootRouteChildren)
+9
apps/frontend/src/routes/profile/$did.tsx
··· 1 + import { createFileRoute } from '@tanstack/react-router' 2 + 3 + export const Route = createFileRoute('/profile/$did')({ 4 + component: RouteComponent, 5 + }) 6 + 7 + function RouteComponent() { 8 + return <div>Hello "/tracks/$did"!</div> 9 + }