UNPKG

mineplex

Version:
86 lines (85 loc) 3.9 kB
"use strict"; var Promise = require("bluebird"); var chai = require("chai"); var chaiAsPromised = require("chai-as-promised"); var _1 = require("../"); chai.use(chaiAsPromised); chai.should(); var VALID_API_KEY = ""; describe("MineplexAPI", function () { var validApi = new _1.MineplexAPI(VALID_API_KEY); describe("Endpoint Interface", function () { describe("player", function () { it("getPlayer", function () { return validApi.getPlayer("Phinary").then(function (player) { player.should.exist; player.name.should.equal("Phinary"); player.uuid.should.equal("b33207e2-0dc5-4cbd-b3ee-6c860727f722"); player.rank.should.be.a("string"); player.shards.should.be.a("number"); player.gems.should.be.a("number"); player.lastLogin.should.be.a("string"); player.level.should.include.keys(["value", "color"]); player.friends.should.be.an.instanceof(Array); player.friends.forEach(function (f) { f.should.have.all.keys("name", "uuid"); }); }); }); it("getPlayerFriends", function () { return validApi.getPlayerFriends("Phinary").then(function (friends) { friends.should.exist; friends.should.be.an.instanceof(Array); }); }); it("getPlayerStatus", function () { return validApi.getPlayerStatus("Phinary").then(function (status) { status.should.exist; status.online.should.be.a("boolean"); }); }); }); describe("network", function () { it("getNetworkStatus", function () { return validApi.getNetworkStatus().then(function (status) { status.should.exist; status.US.should.exist.and.have.all.keys("status", "playerCount", "motd"); status.EU.should.exist.and.have.all.keys("status", "playerCount", "motd"); status.playerCount.should.be.a("number"); }); }); it("getRegionStatus", function () { var us = validApi.getRegionStatus("US"); var eu = validApi.getRegionStatus("EU"); return Promise.join(us, eu, function (usStatus, euStatus) { usStatus.should.exist; euStatus.should.exist; usStatus.should.exist.and.have.all.keys("status", "playerCount", "motd"); euStatus.should.exist.and.have.all.keys("status", "playerCount", "motd"); }); }); }); describe("amplifier", function () { it("getAmplifierGroups", function () { return validApi.getAmplifierGroups().then(function (groups) { groups.should.exist.and.be.an.instanceof(Array); }); }); it("getAmplifiers", function () { return validApi.getAmplifiers("UHC").then(function (amps) { amps.should.be.an.instanceof(Array); if (amps.length > 0) { var amp = amps[0]; amp.should.exist.and.have.all.keys("playerName", "uuid", "duration", "activationTime", "multiplier", "startTime", "endTime"); } }); }); }); }); describe("Errors", function () { it("invalid api key", function () { var api = new _1.MineplexAPI("poop"); return api.getPlayer("Phinary").should.eventually.be.rejected.and.be.an.instanceof(_1.APIError); }); }); });