Skip to content

Commit

Permalink
chore: add msw handlers for bucnation page
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbyerley committed Jul 20, 2024
1 parent 1ec9140 commit 05cbb59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests/mocks/bucnation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { HttpResponse, http, passthrough, type HttpHandler } from 'msw'

const { json } = HttpResponse
const hoopsApi = process.env.HOOPS_API;

const passthroughBucnation = process.env.NODE_ENV !== 'test'

export const handlers: Array<HttpHandler> = [
http.get(`${hoopsApi}/api/etsu/roster`, async ({ request }) => {

Check warning on line 9 in tests/mocks/bucnation.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'request' is defined but never used. Allowed unused args must match /^_/u
if (passthroughBucnation) return passthrough();

return json({ test: 'testroster' })
}),
http.get(`${hoopsApi}/api/etsu/schedule`, async ({ request }) => {

Check warning on line 14 in tests/mocks/bucnation.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'request' is defined but never used. Allowed unused args must match /^_/u
if (passthroughBucnation) return passthrough();

return json({ test: 'testschedule' })
}),
http.get(`${hoopsApi}/api/etsu/stats`, async ({ request }) => {

Check warning on line 19 in tests/mocks/bucnation.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

'request' is defined but never used. Allowed unused args must match /^_/u
if (passthroughBucnation) return passthrough();

return json({ test: 'teststats' })
}),
]
3 changes: 2 additions & 1 deletion tests/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import closeWithGrace from 'close-with-grace'
import { setupServer } from 'msw/node'
import { handlers as githubHandlers } from './github.ts'
import { handlers as resendHandlers } from './resend.ts'
import { handlers as bucnationHandlers } from './bucnation.ts';

Check warning on line 5 in tests/mocks/index.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

`./bucnation.ts` import should occur before import of `./github.ts`

export const server = setupServer(...resendHandlers, ...githubHandlers)
export const server = setupServer(...resendHandlers, ...githubHandlers, ...bucnationHandlers)

server.listen({
onUnhandledRequest(request, print) {
Expand Down

0 comments on commit 05cbb59

Please sign in to comment.