refactor(web): add test-utils helpers for likes/quarantine/track/appState mocks (#375)
Pre-sweep checkpoint. Adds: - fixtures/track.ts — makeTrack() / makeTracks(n) (18 files duplicate today) - mocks/likes.ts — emptyLikesMock() (19 files duplicate today) - mocks/quarantine.ts — emptyQuarantineMock() (9 files duplicate today) - mocks/appState.ts — pageUrlModule(state) (8 files duplicate today) The sweep commits that follow update test files to use these helpers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Fixture builders for TrackRef. Use in test setup to avoid
|
||||
// re-declaring the same literal across 18+ files.
|
||||
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
|
||||
export function makeTrack(overrides: Partial<TrackRef> = {}): TrackRef {
|
||||
return {
|
||||
id: 't1',
|
||||
title: 'Test Track',
|
||||
album_id: 'a1',
|
||||
album_title: 'Test Album',
|
||||
artist_id: 'ar1',
|
||||
artist_name: 'Test Artist',
|
||||
track_number: 1,
|
||||
disc_number: 1,
|
||||
duration_sec: 180,
|
||||
stream_url: '/api/tracks/t1/stream',
|
||||
...overrides
|
||||
};
|
||||
}
|
||||
|
||||
export function makeTracks(n: number, overrides: Partial<TrackRef> = {}): TrackRef[] {
|
||||
return Array.from({ length: n }, (_, i) =>
|
||||
makeTrack({
|
||||
id: `t${i + 1}`,
|
||||
title: `Test Track ${i + 1}`,
|
||||
stream_url: `/api/tracks/t${i + 1}/stream`,
|
||||
...overrides
|
||||
})
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user