fix: use new list item routes

This commit is contained in:
2026-09-01 15:57:09 +02:00
parent 6196556012
commit f35009822f
2 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -119,7 +119,7 @@ describe('lists API', () => {
await expect(createListApi({ name: 'x' })).rejects.toThrow('Failed')
})
it('createListItemApi sends POST to /lists/item and returns the created item with its server id', async () => {
it('createListItemApi sends POST to /lists/items and returns the created item with its server id', async () => {
const mockItem = { id: 'item-1', list_id: '', title: 'Milk', is_completed: false }
const fetchMock = vi.fn<typeof fetch>().mockResolvedValueOnce({
ok: true,
@@ -131,13 +131,13 @@ describe('lists API', () => {
const result = await createListItemApi({ list_id: 'list-1', title: 'Milk' })
expect(fetchMock).toHaveBeenCalledWith(
`${API_BASE_URL}/lists/item`,
`${API_BASE_URL}/lists/items`,
expect.objectContaining({ method: 'POST' }),
)
expect(result).toEqual(mockItem)
})
it('updateListItemApi sends PUT to /lists/item', async () => {
it('updateListItemApi sends PUT to /lists/items', async () => {
const fetchMock = vi.fn<typeof fetch>().mockResolvedValueOnce({
ok: true,
status: 204,
@@ -147,7 +147,7 @@ describe('lists API', () => {
await updateListItemApi({ list_item_id: 'item-1', is_completed: true })
expect(fetchMock).toHaveBeenCalledWith(
`${API_BASE_URL}/lists/item`,
`${API_BASE_URL}/lists/items`,
expect.objectContaining({ method: 'PUT' }),
)
})
@@ -206,7 +206,7 @@ describe('lists API', () => {
await expect(deleteListApi('list-1')).rejects.toThrow('List not found')
})
it('deleteListItemApi sends DELETE to /lists/item/{id}', async () => {
it('deleteListItemApi sends DELETE to /lists/items/{id}', async () => {
const fetchMock = vi.fn<typeof fetch>().mockResolvedValueOnce({
ok: true,
status: 204,
@@ -216,7 +216,7 @@ describe('lists API', () => {
await deleteListItemApi('item-1')
expect(fetchMock).toHaveBeenCalledWith(
`${API_BASE_URL}/lists/item/item-1`,
`${API_BASE_URL}/lists/items/item-1`,
expect.objectContaining({ method: 'DELETE' }),
)
})
+3 -3
View File
@@ -36,7 +36,7 @@ export async function getListItemsApi(listId: string): Promise<ListItem[]> {
}
export async function createListItemApi(payload: CreateListItemPayload): Promise<ListItem> {
const response = await apiClient.post('/lists/item', payload)
const response = await apiClient.post('/lists/items', payload)
if (!response.ok) {
throw new Error(await extractErrorMessage(response, 'Failed to create list item'))
}
@@ -44,7 +44,7 @@ export async function createListItemApi(payload: CreateListItemPayload): Promise
}
export async function updateListItemApi(payload: UpdateListItemPayload): Promise<void> {
const response = await apiClient.put('/lists/item', payload)
const response = await apiClient.put('/lists/items', payload)
if (!response.ok) {
throw new Error(await extractErrorMessage(response, 'Failed to update list item'))
}
@@ -82,7 +82,7 @@ export async function deleteListApi(listId: string): Promise<void> {
}
export async function deleteListItemApi(itemId: string): Promise<void> {
const response = await apiClient.delete(`/lists/item/${itemId}`)
const response = await apiClient.delete(`/lists/items/${itemId}`)
if (!response.ok) {
throw new Error(await extractErrorMessage(response, 'Failed to delete list item'))
}