Skip to content

Commit 05cbb59

Browse files
committed
chore: add msw handlers for bucnation page
1 parent 1ec9140 commit 05cbb59

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tests/mocks/bucnation.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { HttpResponse, http, passthrough, type HttpHandler } from 'msw'
2+
3+
const { json } = HttpResponse
4+
const hoopsApi = process.env.HOOPS_API;
5+
6+
const passthroughBucnation = process.env.NODE_ENV !== 'test'
7+
8+
export const handlers: Array<HttpHandler> = [
9+
http.get(`${hoopsApi}/api/etsu/roster`, async ({ request }) => {
10+
if (passthroughBucnation) return passthrough();
11+
12+
return json({ test: 'testroster' })
13+
}),
14+
http.get(`${hoopsApi}/api/etsu/schedule`, async ({ request }) => {
15+
if (passthroughBucnation) return passthrough();
16+
17+
return json({ test: 'testschedule' })
18+
}),
19+
http.get(`${hoopsApi}/api/etsu/stats`, async ({ request }) => {
20+
if (passthroughBucnation) return passthrough();
21+
22+
return json({ test: 'teststats' })
23+
}),
24+
]

tests/mocks/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import closeWithGrace from 'close-with-grace'
22
import { setupServer } from 'msw/node'
33
import { handlers as githubHandlers } from './github.ts'
44
import { handlers as resendHandlers } from './resend.ts'
5+
import { handlers as bucnationHandlers } from './bucnation.ts';
56

6-
export const server = setupServer(...resendHandlers, ...githubHandlers)
7+
export const server = setupServer(...resendHandlers, ...githubHandlers, ...bucnationHandlers)
78

89
server.listen({
910
onUnhandledRequest(request, print) {

0 commit comments

Comments
 (0)