myanimelist-url-to-id
Version:
MyAnimeList raw URL to ID
27 lines (26 loc) • 1.48 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 CharaUtil_1 = require("../CharaUtil");
describe('Should be able to parse Character Url', function () {
test('Normal Url ', function () {
expect(CharaUtil_1.getCharaId('https://myanimelist.net/character/81239/Yuuma_Kuga')).toBe(81239);
expect(CharaUtil_1.getCharaId('https://myanimelist.net/character/27/Killua_Zoldyck')).toBe(27);
expect(CharaUtil_1.getCharaId('https://myanimelist.net/character/30')).toBe(30);
});
test('Able to detect anomaly Url', function () {
// Wrong base URL
expect(function () { return CharaUtil_1.getCharaId('https://myanimlist.net/character/144919/Ray'); }).toThrow(InvalidUrl_1.default);
// Wrong Path
expect(function () { return CharaUtil_1.getCharaId('https://myanimelist.net/chara/24592'); }).toThrow(InvalidUrl_1.default);
expect(function () { return CharaUtil_1.getCharaId('https://myanimelist.net/chara/150888/Phil'); }).toThrow(InvalidUrl_1.default);
});
});
describe('should be able to generate Character Url', function () {
test('with given ID', function () {
expect(CharaUtil_1.getCharaUrl(12)).toBe('https://myanimelist.net/character/12');
});
});