This commit is contained in:
parent
834ae9df44
commit
fbbb4e1483
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "restfulmc-lib",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"author": "Braydon (Rainnny) <braydonrainnny@gmail.com>",
|
||||
"description": "A simple, yet useful RESTful API for Minecraft utilizing Springboot.",
|
||||
"keywords": [
|
||||
|
@ -1,35 +0,0 @@
|
||||
import { describe, it } from "bun:test";
|
||||
import { getMinecraftServer, getMojangServerStatus, getPlayer } from "../src";
|
||||
import { ErrorResponse } from "../src/types/generic";
|
||||
import { MojangServerStatus } from "../src/types/mojang";
|
||||
import { CachedPlayer } from "../src/types/player";
|
||||
import { CachedBedrockMinecraftServer } from "../src/types/server/bedrock-server";
|
||||
import { CachedJavaMinecraftServer } from "../src/types/server/java-server";
|
||||
|
||||
describe("player", () => {
|
||||
it("Rainnny", async () => {
|
||||
try {
|
||||
const player: CachedPlayer = await getPlayer("Rainnny");
|
||||
console.log(`Hello ${player.username}, your UUID is ${player.uniqueId}!`);
|
||||
} catch (err) {
|
||||
if ((err as ErrorResponse).code == 404) {
|
||||
console.error("Player with UUID or username not found.");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("server", () => {
|
||||
it("java", async () => {
|
||||
const server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer =
|
||||
await getMinecraftServer("java", "play.wildnetwork.net");
|
||||
console.log(server.ip);
|
||||
});
|
||||
});
|
||||
|
||||
describe("mojang", () => {
|
||||
it("status", async () => {
|
||||
const status: MojangServerStatus = await getMojangServerStatus();
|
||||
console.log(status["https://sessionserver.mojang.com"]);
|
||||
});
|
||||
});
|
46
JS-SDK/test/player.test.ts
Normal file
46
JS-SDK/test/player.test.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { getPlayer, getSkinPart } from "@/index";
|
||||
import { ErrorResponse } from "@/types/generic";
|
||||
import { CachedPlayer, SkinPart } from "@/types/player";
|
||||
import { expect, test } from "bun:test";
|
||||
|
||||
/**
|
||||
* Run a test to ensure retrieving
|
||||
* a player's data is successful.
|
||||
*/
|
||||
test("ensurePlayerLookupSuccess", async () => {
|
||||
const player: CachedPlayer = await getPlayer("Rainnny"); // Fetch the player
|
||||
expect(player.username).toBe("Rainnny");
|
||||
});
|
||||
|
||||
/**
|
||||
* Run a test to ensure retrieving an
|
||||
* invalid player results in a 404.
|
||||
*/
|
||||
test("ensurePlayerNotFound", async () => {
|
||||
try {
|
||||
await getPlayer("SDFSDFSDFSDFDDDG"); // Fetch the unknown player
|
||||
} catch (err) {
|
||||
expect((err as ErrorResponse).code).toBe(404);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Run a test to ensure retrieving a player
|
||||
* with an invalid username results in a 400.
|
||||
*/
|
||||
test("ensureUsernameIsInvalid", async () => {
|
||||
try {
|
||||
await getPlayer("A"); // Fetch the invalid player
|
||||
} catch (err) {
|
||||
expect((err as ErrorResponse).code).toBe(400);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Run a test to ensure retrieving a
|
||||
* player's skin part texture is successful.
|
||||
*/
|
||||
test("ensureSkinPartTextureSuccess", async () => {
|
||||
const partTexture: ArrayBuffer = await getSkinPart(SkinPart.HEAD, "Rainnny"); // Fetch the skin part
|
||||
expect(partTexture.byteLength).toBeGreaterThan(0);
|
||||
});
|
Loading…
Reference in New Issue
Block a user