// FE-API-PLACE-HISTORY-001 // // PLC-14: the history pins its verb, its path and its query, and hands back // what the server answered. import { http, HttpResponse } from 'msw'; import { describe, expect, it } from 'vitest'; import { server } from '../../tests/helpers/msw/server'; import { placeHistoryApi } from './placeHistory'; const BASE = '/api/addons/collections/library/places'; describe('placeHistoryApi', () => { it('FE-API-PLACE-HISTORY-001: reads the history of the trip place or saved place it names, page by page', async () => { const calls: Array<{ path: string; query: Record }> = []; const page = { entries: [], next_cursor: null }; const record = ({ request }: { request: Request }) => { const url = new URL(request.url); calls.push({ path: url.pathname, query: Object.fromEntries(url.searchParams) }); return HttpResponse.json(page); }; server.use(http.get(`${BASE}/trip/4/history`, record), http.get(`${BASE}/list/9/history`, record)); expect(await placeHistoryApi.history('trip', 4)).toEqual(page); expect(await placeHistoryApi.history('list', 9, { cursor: '12', limit: 20 })).toEqual(page); expect(calls).toEqual([ { path: `${BASE}/trip/4/history`, query: {} }, { path: `${BASE}/list/9/history`, query: { cursor: '12', limit: '20' } }, ]); }); });