-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathfetch.test.ts
29 lines (27 loc) · 1.13 KB
/
fetch.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { parseFetchArgs } from '../../src/instrument/fetch';
describe('instrument > parseFetchArgs', () => {
it.each([
['string URL only', ['http://example.com'], { method: 'GET', url: 'http://example.com' }],
['URL object only', [new URL('http://example.com')], { method: 'GET', url: 'http://example.com/' }],
['Request URL only', [{ url: 'http://example.com' }], { method: 'GET', url: 'http://example.com' }],
[
'Request URL & method only',
[{ url: 'http://example.com', method: 'post' }],
{ method: 'POST', url: 'http://example.com' },
],
['string URL & options', ['http://example.com', { method: 'post' }], { method: 'POST', url: 'http://example.com' }],
[
'URL object & options',
[new URL('http://example.com'), { method: 'post' }],
{ method: 'POST', url: 'http://example.com/' },
],
[
'Request URL & options',
[{ url: 'http://example.com' }, { method: 'post' }],
{ method: 'POST', url: 'http://example.com' },
],
])('%s', (_name, args, expected) => {
const actual = parseFetchArgs(args as unknown[]);
expect(actual).toEqual(expected);
});
});