Adrià Vilanova Martínez | 01038b2 | 2025-04-05 17:20:01 +0200 | [diff] [blame] | 1 | import { describe, expect, it } from 'vitest'; |
Adrià Vilanova Martínez | 9c418ab | 2024-12-05 15:34:40 +0100 | [diff] [blame] | 2 | import FetchInput from './FetchInput'; |
| 3 | |
| 4 | describe('FetchInput', () => { |
| 5 | describe('getUrl', () => { |
| 6 | const urlString = 'https://example.avm99963.com/'; |
| 7 | |
| 8 | it('should return input when input is already a string', () => { |
| 9 | const dummyInput = urlString; |
| 10 | |
| 11 | const sut = new FetchInput(dummyInput); |
| 12 | const result = sut.getUrl(); |
| 13 | |
| 14 | expect(result).toBe(urlString); |
| 15 | }); |
| 16 | |
| 17 | it('should return stringified url when input is a URL instance', () => { |
| 18 | const dummyInput = new URL(urlString); |
| 19 | |
| 20 | const sut = new FetchInput(dummyInput); |
| 21 | const result = sut.getUrl(); |
| 22 | |
| 23 | expect(result).toBe(urlString); |
| 24 | }); |
| 25 | |
| 26 | it('should return url string when input is a Request instance', () => { |
| 27 | const dummyInput = new Request(urlString); |
| 28 | |
| 29 | const sut = new FetchInput(dummyInput); |
| 30 | const result = sut.getUrl(); |
| 31 | |
| 32 | expect(result).toBe(urlString); |
| 33 | }); |
| 34 | }); |
| 35 | }); |