From 1ba59be463abe60448b0eb7da157251c393c0590 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 3 Sep 2025 10:29:13 +0200 Subject: bgurls --- webAO/__tests__/tryBackgroundUrls.test.ts | 28 ++++++++++++++++++++++++++++ webAO/__tests__/tryUrls.test.ts | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 webAO/__tests__/tryBackgroundUrls.test.ts delete mode 100644 webAO/__tests__/tryUrls.test.ts (limited to 'webAO/__tests__') 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; + +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); + }); +}); diff --git a/webAO/__tests__/tryUrls.test.ts b/webAO/__tests__/tryUrls.test.ts deleted file mode 100644 index 4a32f32..0000000 --- a/webAO/__tests__/tryUrls.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import fileExists from "../utils/fileExists"; -import tryUrls from "../utils/tryUrls"; -import transparentPng from "../constants/transparentPng"; -jest.mock("../utils/fileExists"); - -const mockFileExists = fileExists as jest.MockedFunction; - -describe("tryUrls", () => { - 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 tryUrls(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 tryUrls(url); - const expected = transparentPng; - expect(actual).toBe(expected); - }); -}); -- cgit