tangled
alpha
login
or
join now
ansxor.ca
/
catnip
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
test(api): made utils file for tests
ansxor.ca
6 days ago
c7529905
d8a425aa
+65
-3
3 changed files
expand all
collapse all
unified
split
apps
api
tests
utils.ts
frontend
src
routeTree.gen.ts
routes
profile
$did.tsx
+35
apps/api/tests/utils.ts
···
1
1
+
import { test, expect, beforeAll, afterAll, beforeEach, afterEach } from "bun:test";
2
2
+
import { setupTestDb, teardownTestDb } from "db/test-utils";
3
3
+
import type { InferOutput } from "@atcute/lexicons/validations";
4
4
+
import type { CaAnsxorCatnipTrack } from "lexicon/atcute-lexicon";
5
5
+
import router from "../index";
6
6
+
7
7
+
let db: Awaited<ReturnType<typeof setupTestDb>>;
8
8
+
let txDb: typeof db;
9
9
+
let rollback: () => void;
10
10
+
11
11
+
beforeAll(async () => {
12
12
+
db = await setupTestDb();
13
13
+
});
14
14
+
15
15
+
afterAll(async () => {
16
16
+
await teardownTestDb();
17
17
+
});
18
18
+
19
19
+
beforeEach(async () => {
20
20
+
await new Promise<void>((resolveSetup) => {
21
21
+
let rejectTx: (err: Error) => void;
22
22
+
db.transaction(async (tx) => {
23
23
+
txDb = tx as unknown as typeof db;
24
24
+
resolveSetup();
25
25
+
await new Promise<void>((_, reject) => {
26
26
+
rejectTx = reject;
27
27
+
});
28
28
+
}).catch(() => {});
29
29
+
rollback = () => rejectTx(new Error("rollback"));
30
30
+
});
31
31
+
});
32
32
+
33
33
+
afterEach(() => {
34
34
+
rollback();
35
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
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
24
+
getParentRoute: () => rootRouteImport,
25
25
+
} as any)
26
26
+
const ProfileDidRoute = ProfileDidRouteImport.update({
27
27
+
id: '/profile/$did',
28
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
35
+
'/profile/$did': typeof ProfileDidRoute
29
36
}
30
37
export interface FileRoutesByTo {
31
38
'/': typeof IndexRoute
32
39
'/about': typeof AboutRoute
40
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
46
+
'/profile/$did': typeof ProfileDidRoute
38
47
}
39
48
export interface FileRouteTypes {
40
49
fileRoutesByFullPath: FileRoutesByFullPath
41
41
-
fullPaths: '/' | '/about'
50
50
+
fullPaths: '/' | '/about' | '/profile/$did'
42
51
fileRoutesByTo: FileRoutesByTo
43
43
-
to: '/' | '/about'
44
44
-
id: '__root__' | '/' | '/about'
52
52
+
to: '/' | '/about' | '/profile/$did'
53
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
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
78
+
'/profile/$did': {
79
79
+
id: '/profile/$did'
80
80
+
path: '/profile/$did'
81
81
+
fullPath: '/profile/$did'
82
82
+
preLoaderRoute: typeof ProfileDidRouteImport
83
83
+
parentRoute: typeof rootRouteImport
84
84
+
}
68
85
}
69
86
}
70
87
71
88
const rootRouteChildren: RootRouteChildren = {
72
89
IndexRoute: IndexRoute,
73
90
AboutRoute: AboutRoute,
91
91
+
ProfileDidRoute: ProfileDidRoute,
74
92
}
75
93
export const routeTree = rootRouteImport
76
94
._addFileChildren(rootRouteChildren)
+9
apps/frontend/src/routes/profile/$did.tsx
···
1
1
+
import { createFileRoute } from '@tanstack/react-router'
2
2
+
3
3
+
export const Route = createFileRoute('/profile/$did')({
4
4
+
component: RouteComponent,
5
5
+
})
6
6
+
7
7
+
function RouteComponent() {
8
8
+
return <div>Hello "/tracks/$did"!</div>
9
9
+
}