myanimelist-url-to-id
Version:
MyAnimeList raw URL to ID
26 lines (25 loc) • 1.39 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var InvalidUrl_1 = __importDefault(require("../exceptions/InvalidUrl"));
var MangaUtil_1 = require("../MangaUtil");
describe('Should be able to parse Anime Url', function () {
test('Normal Url ', function () {
expect(MangaUtil_1.getMangaId('https://myanimelist.net/manga/91941/Made_in_Abyss')).toBe(91941);
expect(MangaUtil_1.getMangaId('https://myanimelist.net/manga/105084')).toBe(105084);
});
test('Able to detect anomaly Url', function () {
// Wrong base URL
expect(function () { return MangaUtil_1.getMangaId('https://myanimlist.net/manga/25/Fullmetal_Alchemist'); }).toThrow(InvalidUrl_1.default);
// Wrong Path
expect(function () { return MangaUtil_1.getMangaId('https://myanimelist.net/mangga/48151/World_Trigger'); }).toThrow(InvalidUrl_1.default);
expect(function () { return MangaUtil_1.getMangaId('https://myanimelist.net/mangga/48151'); }).toThrow(InvalidUrl_1.default);
});
});
describe('should be able to generate Anime Url', function () {
test('with given ID', function () {
expect(MangaUtil_1.getMangaUrl(75989)).toBe('https://myanimelist.net/manga/75989');
});
});