blob: 3c20b5bcbbd976b33595b3b36d608024bbcbb676 [file] [log] [blame]
Adrià Vilanova Martínez9c418ab2024-12-05 15:34:40 +01001/**
2 * @jest-environment ./src/xhrInterceptor/fetchProxy/__environments__/fetchEnvironment.ts
3 */
4
5import { describe, expect, it } from '@jest/globals';
6import FetchInput from './FetchInput';
7
8describe('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});