RESTfulMC/JS-SDK/test/index.test.ts
Rainnny7 76201edd92
Some checks failed
Publish JS SDK / docker (push) Failing after 18s
Lib -> JS-SDK
2024-04-15 07:20:56 -04:00

36 lines
1.2 KiB
TypeScript

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"]);
});
});