import { describe, expect, it } from "vitest"; import { pickRatingBadge } from "./plexRating"; describe("pickRatingBadge", () => { it("prefers the IMDb score and marks it as IMDb (gets the imdb.com link)", () => { expect(pickRatingBadge(8.6, 6.0)).toEqual({ score: 8.6, isImdb: true }); }); it("falls back to the audience score without IMDb branding when there's no IMDb score", () => { expect(pickRatingBadge(null, 7.2)).toEqual({ score: 7.2, isImdb: false }); expect(pickRatingBadge(undefined, 7.2)).toEqual({ score: 7.2, isImdb: false }); }); it("treats a 0 IMDb score as present (not falsy-skipped)", () => { expect(pickRatingBadge(0, 5)).toEqual({ score: 0, isImdb: true }); }); it("returns null when neither score exists (no badge rendered)", () => { expect(pickRatingBadge(null, null)).toBeNull(); expect(pickRatingBadge(undefined, undefined)).toBeNull(); }); });