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,33 @@
|
||||
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
vi.mock('./client', () => ({
|
||||
api: { get: vi.fn() }
|
||||
}));
|
||||
|
||||
import { listAlbumsAlpha } from './albums';
|
||||
import { qk } from './queries';
|
||||
import { api } from './client';
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
describe('albums client', () => {
|
||||
test('listAlbumsAlpha hits /api/library/albums with paging', async () => {
|
||||
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
|
||||
items: [], total: 0, limit: 50, offset: 0
|
||||
});
|
||||
await listAlbumsAlpha(50, 0);
|
||||
expect(api.get).toHaveBeenCalledWith('/api/library/albums?limit=50&offset=0');
|
||||
});
|
||||
|
||||
test('listAlbumsAlpha honors custom limit and offset', async () => {
|
||||
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
|
||||
items: [], total: 0, limit: 25, offset: 100
|
||||
});
|
||||
await listAlbumsAlpha(25, 100);
|
||||
expect(api.get).toHaveBeenCalledWith('/api/library/albums?limit=25&offset=100');
|
||||
});
|
||||
|
||||
test('qk.albumsAlpha key is stable', () => {
|
||||
expect(qk.albumsAlpha()).toEqual(['albumsAlpha']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user