fix(web/test): update playlist API tests for api.* call surface (#375)
After e8eff1b migrated playlists.ts from raw apiFetch to the api.*
wrapper, three test files mocked the wrong surface:
- playlists.test.ts: GET case asserted init.method === 'GET' but
api.get omits init.method entirely (fetch defaults to GET). Fall
back to 'GET' when init.method is undefined.
- playlists.refresh-discover.test.ts: re-mock ./client to expose
`api: { post: vi.fn() }` instead of `apiFetch`; assertions check
api.post call args.
- playlists.refresh-foryou.test.ts: same.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,8 @@ describe('playlists API helper', () => {
|
||||
expect(r.public).toEqual([]);
|
||||
const call = spy.mock.calls[0];
|
||||
expect(call[0]).toBe('/api/playlists?kind=user');
|
||||
expect((call[1] as RequestInit).method).toBe('GET');
|
||||
// GET is fetch's default method; api.get omits init.method entirely.
|
||||
expect((call[1] as RequestInit | undefined)?.method ?? 'GET').toBe('GET');
|
||||
});
|
||||
|
||||
test('listPlaylists passes kind=system through the query string', async () => {
|
||||
|
||||
Reference in New Issue
Block a user