diff --git a/src/api/__tests__/lists.spec.ts b/src/api/__tests__/lists.spec.ts index ddacd52..4e3accf 100644 --- a/src/api/__tests__/lists.spec.ts +++ b/src/api/__tests__/lists.spec.ts @@ -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().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().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().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' }), ) }) diff --git a/src/api/lists.ts b/src/api/lists.ts index e673a85..2451165 100644 --- a/src/api/lists.ts +++ b/src/api/lists.ts @@ -36,7 +36,7 @@ export async function getListItemsApi(listId: string): Promise { } export async function createListItemApi(payload: CreateListItemPayload): Promise { - 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 { - 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 { } export async function deleteListItemApi(itemId: string): Promise { - 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')) }