stremio/apps/master-api/src/opensubtitles/org-client.test.ts

18 lines
919 B
TypeScript

import { imdbIdsMatch, normalizeImdbForUrl } from "./org-client";
function assert(cond: unknown, msg: string): asserts cond {
if (!cond) throw new Error(msg);
}
assert(normalizeImdbForUrl("tt0468569") === "0468569", "pad Dark Knight");
assert(normalizeImdbForUrl("468569") === "0468569", "pad short id");
assert(normalizeImdbForUrl("0468569") === "0468569", "keep padded");
assert(normalizeImdbForUrl("tt1375666") === "1375666", "no over-pad Inception");
assert(normalizeImdbForUrl("1375666") === "1375666", "7-digit unchanged");
assert(normalizeImdbForUrl("tt0111161") === "0111161", "Shawshank pad");
assert(normalizeImdbForUrl(null) === null, "null");
assert(imdbIdsMatch("0468569", "468569"), "match padded vs short");
assert(imdbIdsMatch("0111161", "111161"), "match shawshank forms");
assert(!imdbIdsMatch("0468569", "1375666"), "different titles");
console.log("opensubtitles/org-client imdb helpers: ok");