UNPKG

runelite

Version:
63 lines (62 loc) 3.22 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 chai = require("chai"); const chaiAsPromised = require("chai-as-promised"); const API = require("../src/index"); chai.use(chaiAsPromised); const useragent = "https://github.com/nyan-left/runelite-grand-exchange-prices automated tests"; describe("/latest endpoint", () => { it("resolves all items", () => __awaiter(void 0, void 0, void 0, function* () { const latest = yield API.latest({ useragent, }); chai.expect(Object.keys(latest)).to.be.an("array").that.has.length.above(3000); })); it("resolves a specific item", () => __awaiter(void 0, void 0, void 0, function* () { const request = yield API.latest({ id: 4151, useragent }); const transaction = request["4151"]; chai.expect(transaction).to.have.property("high"); chai.expect(transaction).to.have.property("highTime"); chai.expect(transaction).to.have.property("low"); chai.expect(transaction).to.have.property("lowTime"); })); }); describe("/mapping endpoint", () => { it("resolves the mapping data", () => __awaiter(void 0, void 0, void 0, function* () { const mappingData = yield API.mapping({ useragent }); chai.expect(mappingData).to.have.property("4151"); })); }); describe("prices /5m endpoint", () => { it("resolves the 5min data", () => __awaiter(void 0, void 0, void 0, function* () { const minData = yield API.prices({ useragent, timestep: "5m" }); chai.expect(minData).to.have.property("4151"); })); }); describe("prices /1h endpoint", () => { it("resolves the 1hour data", () => __awaiter(void 0, void 0, void 0, function* () { const minData = yield API.prices({ useragent, timestep: "1h" }); chai.expect(minData).to.have.property("4151"); })); }); describe("/timeseries endpoint", () => { it("resolves 300 timesteps", () => __awaiter(void 0, void 0, void 0, function* () { const timeseries = yield API.timeseries({ id: 4151, timestep: "5m", useragent }); chai.expect(timeseries).to.be.an("array").that.has.length(300); const timestep = timeseries[0]; chai.expect(timestep).to.have.property("timestamp"); chai.expect(timestep).to.have.property("lowPriceVolume"); chai.expect(timestep).to.have.property("highPriceVolume"); chai.expect(timestep).to.have.property("avgHighPrice"); chai.expect(timestep).to.have.property("avgLowPrice"); })); });