import { describe, expect, it } from "vitest"; import type { Track } from "../types"; import { buildArtistSummaries } from "./artists"; const track = (id: string, artist: string, albumId: string): Track => ({ id, title: id, artist, album: albumId, albumId, duration: 180, coverTone: "dusk", }); describe("buildArtistSummaries", () => { it("groups artists case-insensitively and counts their albums and tracks", () => { const artists = buildArtistSummaries([ track("song-1", "North Window", "album-1"), track("song-2", "north window", "album-1"), track("song-3", "North Window", "album-2"), track("song-4", "Mara Venn", "album-3"), ]); expect(artists.map((artist) => artist.name)).toEqual(["Mara Venn", "North Window"]); expect(artists[1]).toMatchObject({ albumCount: 2 }); expect(artists[1].tracks).toHaveLength(3); }); });