Files
sofa/lib/services/colors.test.ts
T
jake 4cf326fa00 Add comprehensive test suite with CI workflow
- 211 tests across 15 files covering services (tracking, discovery,
  metadata, backup, credits, webhooks, settings, update-check, colors,
  person), utilities (config, cron, providers, title-theme), and TMDB
  image URL helpers
- `lib/test-preload.ts` + `bunfig.toml` wire up a global in-memory
  SQLite DB with migrations for all DB-backed tests
- `lib/test-utils.ts` provides `clearAllTables()` and seed helpers
  (insertUser, insertTitle, insertTvShow, insertMovieWatch, etc.)
- Export `getBackupSource`, `isKnownBackup`, `isValidBackupFilename`,
  `buildBackupCron`, `performUpdateCheck` internals for direct testing
- GitHub Actions workflow runs `bun test --coverage` on push/PR to main
2026-03-06 13:42:58 -05:00

37 lines
978 B
TypeScript

import { describe, expect, mock, test } from "bun:test";
mock.module("@/lib/services/image-cache", () => ({
downloadAndCacheImage: async () => {},
getLocalImagePath: () => "",
imageCacheEnabled: () => false,
isImageCached: async () => false,
}));
import { parseColorPalette } from "./colors";
describe("parseColorPalette", () => {
test("returns null for null input", () => {
expect(parseColorPalette(null)).toBeNull();
});
test("returns null for empty string", () => {
expect(parseColorPalette("")).toBeNull();
});
test("parses valid JSON", () => {
const palette = {
vibrant: "#e63946",
darkVibrant: "#1d3557",
lightVibrant: "#f1faee",
muted: "#a8dadc",
darkMuted: "#457b9d",
lightMuted: "#f4f4f4",
};
expect(parseColorPalette(JSON.stringify(palette))).toEqual(palette);
});
test("returns null for malformed JSON", () => {
expect(parseColorPalette("{not valid json")).toBeNull();
});
});