This commit is contained in:
parent
3171346d4b
commit
74a3305ddd
13
JS-SDK/test/mojang.test.ts
Normal file
13
JS-SDK/test/mojang.test.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { getMojangServerStatus } from "@/index";
|
||||||
|
import { MojangServerStatus } from "@/types/mojang";
|
||||||
|
import { expect, test } from "bun:test";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure retrieving
|
||||||
|
* the status of Mojang servers is
|
||||||
|
* successful.
|
||||||
|
*/
|
||||||
|
test("ensureServerStatusCheckSuccess", async () => {
|
||||||
|
const status: MojangServerStatus = await getMojangServerStatus(); // Get Mojang service status
|
||||||
|
expect(status).toBeDefined();
|
||||||
|
});
|
76
JS-SDK/test/server.test.ts
Normal file
76
JS-SDK/test/server.test.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import {
|
||||||
|
getJavaServerFavicon,
|
||||||
|
getMinecraftServer,
|
||||||
|
isMojangBlocked,
|
||||||
|
} from "@/index";
|
||||||
|
import { ErrorResponse } from "@/types/generic";
|
||||||
|
import { CachedBedrockMinecraftServer } from "@/types/server/bedrock-server";
|
||||||
|
import { CachedJavaMinecraftServer } from "@/types/server/java-server";
|
||||||
|
import { ServerPlatform } from "@/types/server/server";
|
||||||
|
import { expect, test } from "bun:test";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure retrieving a
|
||||||
|
* Java server's status is successful.
|
||||||
|
*/
|
||||||
|
test("ensureJavaServerLookupSuccess", async () => {
|
||||||
|
const server: CachedJavaMinecraftServer = (await getMinecraftServer(
|
||||||
|
ServerPlatform.JAVA,
|
||||||
|
"hypixel.net"
|
||||||
|
)) as CachedJavaMinecraftServer; // Fetch the Java server
|
||||||
|
expect(server.hostname).toBe("mc.hypixel.net");
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure retrieving a
|
||||||
|
* Bedrock server's status is successful.
|
||||||
|
*/
|
||||||
|
test("ensureBedrockServerLookupSuccess", async () => {
|
||||||
|
const server: CachedBedrockMinecraftServer = (await getMinecraftServer(
|
||||||
|
ServerPlatform.BEDROCK,
|
||||||
|
"wildprison.bedrock.minehut.gg"
|
||||||
|
)) as CachedBedrockMinecraftServer; // Fetch the Bedrock server
|
||||||
|
expect(server.hostname).toBe("wildprison.bedrock.minehut.gg");
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure looking up an
|
||||||
|
* invalid hostname results in a 400.
|
||||||
|
*/
|
||||||
|
test("ensureUnknownHostname", async () => {
|
||||||
|
try {
|
||||||
|
await getMinecraftServer(ServerPlatform.JAVA, "invalid"); // Fetch the unknown server
|
||||||
|
} catch (err) {
|
||||||
|
expect((err as ErrorResponse).code).toBe(400);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure looking up an
|
||||||
|
* invalid port results in a 400.
|
||||||
|
*/
|
||||||
|
test("ensureUnknownPort", async () => {
|
||||||
|
try {
|
||||||
|
await getMinecraftServer(ServerPlatform.JAVA, "hypixel.net:A"); // Fetch the invalid server
|
||||||
|
} catch (err) {
|
||||||
|
expect((err as ErrorResponse).code).toBe(400);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure checking if
|
||||||
|
* a server is blocked is successful.
|
||||||
|
*/
|
||||||
|
test("ensureServerBanCheckSuccess", async () => {
|
||||||
|
const blocked: boolean = await isMojangBlocked("arkhamnetwork.org"); // Check if the server is blocked
|
||||||
|
expect(blocked).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a test to ensure retrieving a
|
||||||
|
* Java server's favicon is successful.
|
||||||
|
*/
|
||||||
|
test("ensureServerFaviconSuccess", async () => {
|
||||||
|
const faviconTexture: ArrayBuffer = await getJavaServerFavicon("hypixel.net"); // Get the Java server's favicon
|
||||||
|
expect(faviconTexture.byteLength).toBeGreaterThan(0);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user