mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
test(places): cover the place sheet sections, tags, trip lists and the visited filter
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// 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<string, string> }> = [];
|
||||
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' } },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user