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 import { Route as rootRouteImport } from './routes/__root' 12 import { Route as AboutRouteImport } from './routes/about' 13 import { Route as IndexRouteImport } from './routes/index' 14 15 const AboutRoute = AboutRouteImport.update({ 16 id: '/about', ··· 20 const IndexRoute = IndexRouteImport.update({ 21 id: '/', 22 path: '/', 23 getParentRoute: () => rootRouteImport, 24 } as any) 25 26 export interface FileRoutesByFullPath { 27 '/': typeof IndexRoute 28 '/about': typeof AboutRoute 29 } 30 export interface FileRoutesByTo { 31 '/': typeof IndexRoute 32 '/about': typeof AboutRoute 33 } 34 export interface FileRoutesById { 35 __root__: typeof rootRouteImport 36 '/': typeof IndexRoute 37 '/about': typeof AboutRoute 38 } 39 export interface FileRouteTypes { 40 fileRoutesByFullPath: FileRoutesByFullPath 41 - fullPaths: '/' | '/about' 42 fileRoutesByTo: FileRoutesByTo 43 - to: '/' | '/about' 44 - id: '__root__' | '/' | '/about' 45 fileRoutesById: FileRoutesById 46 } 47 export interface RootRouteChildren { 48 IndexRoute: typeof IndexRoute 49 AboutRoute: typeof AboutRoute 50 } 51 52 declare module '@tanstack/react-router' { ··· 65 preLoaderRoute: typeof IndexRouteImport 66 parentRoute: typeof rootRouteImport 67 } 68 } 69 } 70 71 const rootRouteChildren: RootRouteChildren = { 72 IndexRoute: IndexRoute, 73 AboutRoute: AboutRoute, 74 } 75 export const routeTree = rootRouteImport 76 ._addFileChildren(rootRouteChildren)
··· 11 import { Route as rootRouteImport } from './routes/__root' 12 import { Route as AboutRouteImport } from './routes/about' 13 import { Route as IndexRouteImport } from './routes/index' 14 + import { Route as ProfileDidRouteImport } from './routes/profile/$did' 15 16 const AboutRoute = AboutRouteImport.update({ 17 id: '/about', ··· 21 const IndexRoute = IndexRouteImport.update({ 22 id: '/', 23 path: '/', 24 + getParentRoute: () => rootRouteImport, 25 + } as any) 26 + const ProfileDidRoute = ProfileDidRouteImport.update({ 27 + id: '/profile/$did', 28 + path: '/profile/$did', 29 getParentRoute: () => rootRouteImport, 30 } as any) 31 32 export interface FileRoutesByFullPath { 33 '/': typeof IndexRoute 34 '/about': typeof AboutRoute 35 + '/profile/$did': typeof ProfileDidRoute 36 } 37 export interface FileRoutesByTo { 38 '/': typeof IndexRoute 39 '/about': typeof AboutRoute 40 + '/profile/$did': typeof ProfileDidRoute 41 } 42 export interface FileRoutesById { 43 __root__: typeof rootRouteImport 44 '/': typeof IndexRoute 45 '/about': typeof AboutRoute 46 + '/profile/$did': typeof ProfileDidRoute 47 } 48 export interface FileRouteTypes { 49 fileRoutesByFullPath: FileRoutesByFullPath 50 + fullPaths: '/' | '/about' | '/profile/$did' 51 fileRoutesByTo: FileRoutesByTo 52 + to: '/' | '/about' | '/profile/$did' 53 + id: '__root__' | '/' | '/about' | '/profile/$did' 54 fileRoutesById: FileRoutesById 55 } 56 export interface RootRouteChildren { 57 IndexRoute: typeof IndexRoute 58 AboutRoute: typeof AboutRoute 59 + ProfileDidRoute: typeof ProfileDidRoute 60 } 61 62 declare module '@tanstack/react-router' { ··· 75 preLoaderRoute: typeof IndexRouteImport 76 parentRoute: typeof rootRouteImport 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 + } 85 } 86 } 87 88 const rootRouteChildren: RootRouteChildren = { 89 IndexRoute: IndexRoute, 90 AboutRoute: AboutRoute, 91 + ProfileDidRoute: ProfileDidRoute, 92 } 93 export const routeTree = rootRouteImport 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 + }