23 lines
887 B
TypeScript
23 lines
887 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { server, http, HttpResponse } from './test-setup'
|
|
import { getRecipe } from '@/api/sdk'
|
|
import { setHouseholdSlugProvider } from '@/api/client'
|
|
|
|
// Drive migration to path-scoped recipes via householdSlug
|
|
|
|
describe('recipes api v2 (household-scoped)', () => {
|
|
it('gets a recipe by id with householdSlug path', async () => {
|
|
server.use(
|
|
http.get('*/api/v1/households/:householdSlug/recipes/:recipe_id', ({ params }) => {
|
|
const { householdSlug, recipe_id } = params
|
|
expect(householdSlug).toBe('the-smiths')
|
|
return HttpResponse.json({ id: Number(recipe_id), name: 'Pancakes', ingredients: [] }, { status: 200 })
|
|
})
|
|
)
|
|
setHouseholdSlugProvider(() => 'the-smiths')
|
|
|
|
const data = await getRecipe('the-smiths', 123)
|
|
expect(data).toBeTruthy()
|
|
expect(data.name).toBe('Pancakes')
|
|
})
|
|
})
|