23 lines
749 B
JavaScript
23 lines
749 B
JavaScript
|
|
import { describe, it, expect } from 'vitest'
|
||
|
|
import { server, http, HttpResponse } from './test-setup'
|
||
|
|
import { getRecipe } from '@/api/sdk'
|
||
|
|
|
||
|
|
// Tests validate the typed client wrapper behavior without needing the backend
|
||
|
|
|
||
|
|
describe('recipes api (typed client)', () => {
|
||
|
|
it('gets a recipe by id', async () => {
|
||
|
|
server.use(
|
||
|
|
http.get('*/api/v1/recipes/:id', ({ params }) => {
|
||
|
|
// eslint-disable-next-line no-console
|
||
|
|
console.log('MSW handler hit with params:', params)
|
||
|
|
const { id } = params
|
||
|
|
return HttpResponse.json({ id, name: 'Pancakes', ingredients: [] }, { status: 200 })
|
||
|
|
})
|
||
|
|
)
|
||
|
|
|
||
|
|
const data = await getRecipe('123')
|
||
|
|
expect(data).toBeTruthy()
|
||
|
|
expect(data.name).toBe('Pancakes')
|
||
|
|
})
|
||
|
|
})
|