aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/__tests__/tryUrls.test.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-03-25 18:32:52 +0100
committerGitHub <noreply@github.com>2022-03-25 18:32:52 +0100
commitd1472f152c8ca9de8d790f9cc88e79d1e3b11be6 (patch)
tree821b8c77722692e60c502ede90664f1b75fde1fc /webAO/utils/__tests__/tryUrls.test.ts
parente4d1e1cd4b361e96aad09d9b5539db44cb1ed8dd (diff)
parent8406b6f1fb6ce6e61dab3e39f1a5751c49e6d184 (diff)
Merge pull request #130 from AttorneyOnline/multipleBackgroundTypes
Multiple Background Types
Diffstat (limited to 'webAO/utils/__tests__/tryUrls.test.ts')
-rw-r--r--webAO/utils/__tests__/tryUrls.test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/webAO/utils/__tests__/tryUrls.test.ts b/webAO/utils/__tests__/tryUrls.test.ts
new file mode 100644
index 0000000..444664e
--- /dev/null
+++ b/webAO/utils/__tests__/tryUrls.test.ts
@@ -0,0 +1,31 @@
+import fileExists from '../fileExists'
+import tryUrls from '../tryUrls';
+import transparentPng from '../../constants/transparentPng'
+jest.mock('../fileExists')
+
+const mockFileExists = fileExists as jest.MockedFunction<typeof fileExists>;
+
+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);
+ });
+})
+
+