mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 02:45:39 -04:00
- 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
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { generateProviderUrl } from "./providers";
|
|
|
|
describe("generateProviderUrl", () => {
|
|
test("generates Netflix URL", () => {
|
|
expect(generateProviderUrl(8, "Inception")).toBe(
|
|
"https://www.netflix.com/search?q=Inception",
|
|
);
|
|
});
|
|
|
|
test("generates Amazon Prime Video URL", () => {
|
|
expect(generateProviderUrl(9, "The Matrix")).toBe(
|
|
"https://www.amazon.com/s?i=instant-video&k=The%20Matrix",
|
|
);
|
|
});
|
|
|
|
test("generates Disney+ URL", () => {
|
|
expect(generateProviderUrl(337, "Frozen")).toBe(
|
|
"https://www.disneyplus.com/search/Frozen",
|
|
);
|
|
});
|
|
|
|
test("URL-encodes spaces", () => {
|
|
expect(generateProviderUrl(8, "The Dark Knight")).toBe(
|
|
"https://www.netflix.com/search?q=The%20Dark%20Knight",
|
|
);
|
|
});
|
|
|
|
test("URL-encodes special characters", () => {
|
|
expect(generateProviderUrl(8, "Tom & Jerry")).toBe(
|
|
"https://www.netflix.com/search?q=Tom%20%26%20Jerry",
|
|
);
|
|
});
|
|
|
|
test("URL-encodes unicode", () => {
|
|
const url = generateProviderUrl(8, "Amelie");
|
|
expect(url).toContain("Amelie");
|
|
expect(url).not.toBeNull();
|
|
});
|
|
|
|
test("returns null for unknown provider ID", () => {
|
|
expect(generateProviderUrl(99999, "Test")).toBeNull();
|
|
});
|
|
|
|
test("generates Hulu URL", () => {
|
|
expect(generateProviderUrl(15, "Test")).toBe(
|
|
"https://www.hulu.com/search?q=Test",
|
|
);
|
|
});
|
|
});
|