diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-03-28 23:41:56 +0200 |
|---|---|---|
| committer | stonedDiscord <Tukz@gmx.de> | 2022-03-28 23:41:56 +0200 |
| commit | 903a13ff5b5beaaf42b4fcf8965eb55b642e1d2a (patch) | |
| tree | 7e7cbf09c1ce6d2539bb2f33a9c3c86f19ce9d48 /webAO/utils/__tests__/tryUrls.test.ts | |
| parent | 06ee582c4adefdb35220c63ee4a30444474e9388 (diff) | |
| parent | d3911aa9ad6bc16c70355fe11d1377d636b14565 (diff) | |
Merge branch 'master' into coolloading
Diffstat (limited to 'webAO/utils/__tests__/tryUrls.test.ts')
| -rw-r--r-- | webAO/utils/__tests__/tryUrls.test.ts | 31 |
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); + }); +}) + + |
