UNPKG

riotg.api

Version:

<a href="https://www.npmjs.com/package/riotg.api"> <img src="https://img.shields.io/static/v1?label=npm&message=riotg.api&color=red&style=for-the-badge&logo=NPM" /> </a>

86 lines (85 loc) 3.9 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require(".."); require("dotenv/config"); const mock_1 = require("./mock"); describe("Summoner", () => { let riotClient; beforeAll(() => (riotClient = new __1.RiotClient({ apiKey: process.env.API_KEY || "", region: "na1", }))); describe("GET BY NAME", () => { it("should be return data of summoner", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByName(mock_1.summonerMock.name); expect(summoner).toEqual(mock_1.summonerMock); })); it("should be return error when summoner not exists", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByName("aiuhsuiahisuhas"); expect(summoner).toEqual(mock_1.errorSummonerNotFound); })); }); describe("GET BY ACCOUNT ID", () => { it("should be return data of summoner", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByAccountId(mock_1.summonerMock.accountId); expect(summoner).toEqual(mock_1.summonerMock); })); it("should be return error when summoner not exists", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByAccountId("aiuhsuiahisuhas"); expect(summoner).toEqual(mock_1.errorSummonerBadRequest); })); }); describe("GET BY PUUID", () => { it("should be return data of summoner", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByPUUID(mock_1.summonerMock.puuid); expect(summoner).toEqual(mock_1.summonerMock); })); it("should be return error when summoner not exists", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getByPUUID("aiuhsuiahisuhas"); expect(summoner).toEqual(mock_1.errorSummonerBadRequest); })); }); describe("GET BY ID", () => { it("should be return data of summoner", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getById(mock_1.summonerMock.id); expect(summoner).toEqual(mock_1.summonerMock); })); it("should be return error when summoner not exists", () => __awaiter(void 0, void 0, void 0, function* () { const summoner = yield riotClient .lol() .summoner() .getById("aiuhsuiahisuhas"); expect(summoner).toEqual(mock_1.errorSummonerBadRequest); })); }); });