aboutsummaryrefslogtreecommitdiff
path: root/webAO/__tests__/tryBackgroundUrls.test.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2025-09-03 10:29:13 +0200
committerstonedDiscord <Tukz@gmx.de>2025-09-03 10:29:13 +0200
commit1ba59be463abe60448b0eb7da157251c393c0590 (patch)
tree4568f364d7ae863970d9c69fceac88e72e9cbbc0 /webAO/__tests__/tryBackgroundUrls.test.ts
parente58dcb7186bb3c80ba87279a6643fcb4b8b3b2be (diff)
bgurls
Diffstat (limited to 'webAO/__tests__/tryBackgroundUrls.test.ts')
-rw-r--r--webAO/__tests__/tryBackgroundUrls.test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/webAO/__tests__/tryBackgroundUrls.test.ts b/webAO/__tests__/tryBackgroundUrls.test.ts
new file mode 100644
index 0000000..cfbf3f9
--- /dev/null
+++ b/webAO/__tests__/tryBackgroundUrls.test.ts
@@ -0,0 +1,28 @@
+import fileExists from "../utils/fileExists";
+import tryBackgroundUrls from "../utils/tryBackgroundUrls";
+import transparentPng from "../constants/transparentPng";
+jest.mock("../utils/fileExists");
+
+const mockFileExists = fileExists as jest.MockedFunction<typeof fileExists>;
+
+describe("tryBackgroundUrls", () => {
+ it("Should try multiple file extensions", async () => {
+ const url = "localhost/stoneddiscord/assets";
+ mockFileExists
+ .mockReturnValueOnce(Promise.resolve(false))
+ .mockReturnValueOnce(Promise.resolve(false))
+ .mockReturnValueOnce(Promise.resolve(false))
+ .mockReturnValueOnce(Promise.resolve(true));
+ const actual = await tryBackgroundUrls(url);
+ const expected = "localhost/stoneddiscord/assets.apng";
+ expect(actual).toBe(expected);
+ });
+
+ it("Should return a transparent png if it cant find any assets", async () => {
+ const url = "localhost/stoneddiscord/assets";
+ mockFileExists.mockReturnValue(Promise.resolve(false));
+ const actual = await tryBackgroundUrls(url);
+ const expected = transparentPng;
+ expect(actual).toBe(expected);
+ });
+});