feat(web): add home/albums/artists API clients for M6a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
vi.mock('./client', () => ({
|
||||
api: { get: vi.fn() }
|
||||
}));
|
||||
|
||||
import { listHome } from './home';
|
||||
import { qk } from './queries';
|
||||
import { api } from './client';
|
||||
import type { HomePayload } from './types';
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
describe('home client', () => {
|
||||
test('listHome hits /api/home', async () => {
|
||||
const fixture: HomePayload = {
|
||||
recently_added_albums: [],
|
||||
rediscover_albums: [],
|
||||
rediscover_artists: [],
|
||||
most_played_tracks: [],
|
||||
last_played_artists: []
|
||||
};
|
||||
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce(fixture);
|
||||
const got = await listHome();
|
||||
expect(api.get).toHaveBeenCalledWith('/api/home');
|
||||
expect(got).toEqual(fixture);
|
||||
});
|
||||
|
||||
test('qk.home key is stable', () => {
|
||||
expect(qk.home()).toEqual(['home']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user