Javascript-Library/test/player.ts

33 lines
933 B
TypeScript
Raw Normal View History

2024-04-15 07:56:26 +00:00
import { getPlayer, getPlayerSkinPart, getPlayerUuid } from "../dist/index";
2024-04-14 20:11:46 +00:00
test("ensureGetPlayerLookupSuccess", async () => {
2024-04-15 07:56:26 +00:00
const response = await getPlayer("Notch");
2024-04-14 20:11:46 +00:00
const { player } = response;
expect(player).toBeDefined();
expect(player).toHaveProperty("username");
});
test("ensureGetPlayerUuidSuccess", async () => {
2024-04-15 07:56:26 +00:00
const player = await getPlayerUuid("Notch");
2024-04-14 20:11:46 +00:00
expect(player).toBeDefined();
expect(player).toHaveProperty("username");
expect(player).toHaveProperty("uniqueId");
});
test("ensureGetPlayerSkinPartSuccess", async () => {
2024-04-15 07:56:26 +00:00
const response = await getPlayer("Notch");
2024-04-14 20:11:46 +00:00
const { player } = response;
const skin = player.skin;
const skinParts = skin.parts;
// Test each skin part
for (const part in skinParts) {
2024-04-15 07:56:26 +00:00
const partBuffer = await getPlayerSkinPart(part, player.uniqueId);
2024-04-14 20:11:46 +00:00
expect(partBuffer).toBeDefined();
expect(partBuffer.byteLength).toBeGreaterThan(0);
}
});