initital commit

This commit is contained in:
Lee
2024-04-14 21:11:46 +01:00
parent 5876f13f70
commit eb0facd38e
25 changed files with 3120 additions and 0 deletions

7
test/mojang.ts Normal file
View File

@ -0,0 +1,7 @@
import mcUtils from "../src/index";
test("ensureMojangEndpointStatusLookupSuccess", async () => {
const response = await mcUtils.mojang.getMojangEndpointStatus();
expect(response).toHaveProperty("endpoints");
});

32
test/player.ts Normal file
View File

@ -0,0 +1,32 @@
import mcUtils from "../src/index";
test("ensureGetPlayerLookupSuccess", async () => {
const response = await mcUtils.player.getPlayer("Notch");
const { player } = response;
expect(player).toBeDefined();
expect(player).toHaveProperty("username");
});
test("ensureGetPlayerUuidSuccess", async () => {
const player = await mcUtils.player.getPlayerUuid("Notch");
expect(player).toBeDefined();
expect(player).toHaveProperty("username");
expect(player).toHaveProperty("uniqueId");
});
test("ensureGetPlayerSkinPartSuccess", async () => {
const response = await mcUtils.player.getPlayer("Notch");
const { player } = response;
const skin = player.skin;
const skinParts = skin.parts;
// Test each skin part
for (const part in skinParts) {
const partBuffer = await mcUtils.player.getPlayerSkinPart(part, player.uniqueId);
expect(partBuffer).toBeDefined();
expect(partBuffer.byteLength).toBeGreaterThan(0);
}
});

21
test/server.ts Normal file
View File

@ -0,0 +1,21 @@
import mcUtils from "../src/index";
import { ServerPlatform } from "../src/types/server/platform";
test("ensureGetServerLookupSuccess", async () => {
const cachedServer = await mcUtils.server.getServer(ServerPlatform.Java, "mc.hypixel.net");
const { server } = cachedServer;
expect(server).toBeDefined();
expect(server).toHaveProperty("hostname"); // The server was found
});
test("ensureGetServerIconSuccess", async () => {
const icon = await mcUtils.server.getServerIcon("mc.hypixel.net");
expect(icon).toBeDefined();
expect(icon.byteLength).toBeGreaterThan(0); // The server has an icon
});
test("ensureGetServerBlockedStatusSuccess", async () => {
const blockedStatus = await mcUtils.server.getBlockedStatus("mc.hypixel.net");
expect(blockedStatus).toBe(false); // The server is not blocked
});