Adrià Vilanova MartÃnez | 9c418ab | 2024-12-05 15:34:40 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @jest-environment ./src/xhrInterceptor/fetchProxy/__environments__/fetchEnvironment.ts |
| 3 | */ |
| 4 | |
| 5 | import { describe, expect, it } from '@jest/globals'; |
| 6 | import FetchInput from './FetchInput'; |
| 7 | |
| 8 | describe('FetchInput', () => { |
| 9 | describe('getUrl', () => { |
| 10 | const urlString = 'https://example.avm99963.com/'; |
| 11 | |
| 12 | it('should return input when input is already a string', () => { |
| 13 | const dummyInput = urlString; |
| 14 | |
| 15 | const sut = new FetchInput(dummyInput); |
| 16 | const result = sut.getUrl(); |
| 17 | |
| 18 | expect(result).toBe(urlString); |
| 19 | }); |
| 20 | |
| 21 | it('should return stringified url when input is a URL instance', () => { |
| 22 | const dummyInput = new URL(urlString); |
| 23 | |
| 24 | const sut = new FetchInput(dummyInput); |
| 25 | const result = sut.getUrl(); |
| 26 | |
| 27 | expect(result).toBe(urlString); |
| 28 | }); |
| 29 | |
| 30 | it('should return url string when input is a Request instance', () => { |
| 31 | const dummyInput = new Request(urlString); |
| 32 | |
| 33 | const sut = new FetchInput(dummyInput); |
| 34 | const result = sut.getUrl(); |
| 35 | |
| 36 | expect(result).toBe(urlString); |
| 37 | }); |
| 38 | }); |
| 39 | }); |