chore(format): run prettier over src/ and scripts/
Formatting was configured but never enforced: `bun run format:check` reported 199 unformatted files and ran in no workflow and in no git hook, so .prettierrc (printWidth 100, trailing commas) described an intention rather than the tree. This is the one-time sweep that makes the check gateable. Whitespace and token-reflow only -- no behavioural change: `bun run check` reports 0 errors and all 1053 frontend tests pass before and after. Kept out of every other commit on purpose. A 199-file diff mixed with real changes is unreviewable, and the next commit turns format:check into a hard CI gate so this cannot silently accumulate again.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { selectDiverseGenres, sampleAcross } from "./genreDiversity";
|
||||
|
||||
const g = (...names: string[]) => names.map(name => ({ name }));
|
||||
const g = (...names: string[]) => names.map((name) => ({ name }));
|
||||
|
||||
describe("sampleAcross", () => {
|
||||
it("returns input unchanged when at or under the count", () => {
|
||||
@@ -32,7 +32,7 @@ describe("selectDiverseGenres", () => {
|
||||
|
||||
it("seeds with the most populous genre (first in input)", () => {
|
||||
const out = selectDiverseGenres(g("Rock", "Jazz", "Hip Hop"), 1);
|
||||
expect(out.map(x => x.name)).toEqual(["Rock"]);
|
||||
expect(out.map((x) => x.name)).toEqual(["Rock"]);
|
||||
});
|
||||
|
||||
it("spreads the family instead of stacking near-synonyms", () => {
|
||||
@@ -45,35 +45,28 @@ describe("selectDiverseGenres", () => {
|
||||
"Pop Rock",
|
||||
"Jazz",
|
||||
"Hip Hop",
|
||||
"Classical"
|
||||
"Classical",
|
||||
);
|
||||
const names = selectDiverseGenres(input, 4).map(x => x.name);
|
||||
const names = selectDiverseGenres(input, 4).map((x) => x.name);
|
||||
|
||||
expect(names[0]).toBe("Rock"); // seeded by count
|
||||
expect(names).toContain("Jazz");
|
||||
expect(names).toContain("Hip Hop");
|
||||
expect(names).toContain("Classical");
|
||||
// Only the seed represents the Rock cluster.
|
||||
expect(names.filter(n => n.includes("Rock"))).toEqual(["Rock"]);
|
||||
expect(names.filter((n) => n.includes("Rock"))).toEqual(["Rock"]);
|
||||
});
|
||||
|
||||
it("preserves count order as the tie-breaker among equally-distinct genres", () => {
|
||||
// All four are mutually distinct (no shared tokens), so every pick after
|
||||
// the seed is a distance tie and should follow input (count) order.
|
||||
const input = g("Rock", "Jazz", "Blues", "Folk");
|
||||
expect(selectDiverseGenres(input, 3).map(x => x.name)).toEqual([
|
||||
"Rock",
|
||||
"Jazz",
|
||||
"Blues",
|
||||
]);
|
||||
expect(selectDiverseGenres(input, 3).map((x) => x.name)).toEqual(["Rock", "Jazz", "Blues"]);
|
||||
});
|
||||
|
||||
it("is case- and separator-insensitive when comparing", () => {
|
||||
const input = g("Hip Hop", "hip-hop", "Reggae");
|
||||
// "Hip Hop" and "hip-hop" share all tokens → the second is redundant.
|
||||
expect(selectDiverseGenres(input, 2).map(x => x.name)).toEqual([
|
||||
"Hip Hop",
|
||||
"Reggae",
|
||||
]);
|
||||
expect(selectDiverseGenres(input, 2).map((x) => x.name)).toEqual(["Hip Hop", "Reggae"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user