feat: filter artist discography + counts to core releases unless showAllTypes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { isCoreRelease } from "./release-filter";
|
||||
|
||||
describe("isCoreRelease", () => {
|
||||
it("accepts Album/Single/EP with no secondary types", () => {
|
||||
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: [] })).toBe(true);
|
||||
expect(isCoreRelease({ primaryType: "Single", secondaryTypes: [] })).toBe(true);
|
||||
expect(isCoreRelease({ primaryType: "EP", secondaryTypes: [] })).toBe(true);
|
||||
});
|
||||
it("rejects secondary types and non-core primaries and null", () => {
|
||||
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: ["Live"] })).toBe(false);
|
||||
expect(isCoreRelease({ primaryType: "Album", secondaryTypes: ["Compilation"] })).toBe(false);
|
||||
expect(isCoreRelease({ primaryType: "Broadcast", secondaryTypes: [] })).toBe(false);
|
||||
expect(isCoreRelease({ primaryType: null, secondaryTypes: [] })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
const CORE_PRIMARY = new Set(["Album", "Single", "EP"]);
|
||||
|
||||
/** A "core" studio release: Album/Single/EP with no secondary types (live, compilation, etc.). */
|
||||
export function isCoreRelease(r: { primaryType: string | null; secondaryTypes: string[] }): boolean {
|
||||
return CORE_PRIMARY.has(r.primaryType ?? "") && r.secondaryTypes.length === 0;
|
||||
}
|
||||
Reference in New Issue
Block a user