|
1 | 1 | import { parseFetchArgs } from '../../../src/utils-hoist/instrument/fetch'; |
2 | 2 |
|
3 | 3 | describe('instrument > parseFetchArgs', () => { |
4 | | - const data = { name: 'Test' }; |
5 | | - |
6 | 4 | it.each([ |
7 | | - ['string URL only', ['http://example.com'], { method: 'GET', url: 'http://example.com', body: null }], |
8 | | - ['URL object only', [new URL('http://example.com')], { method: 'GET', url: 'http://example.com/', body: null }], |
9 | | - ['Request URL only', [{ url: 'http://example.com' }], { method: 'GET', url: 'http://example.com', body: null }], |
| 5 | + ['string URL only', ['http://example.com'], { method: 'GET', url: 'http://example.com' }], |
| 6 | + ['URL object only', [new URL('http://example.com')], { method: 'GET', url: 'http://example.com/' }], |
| 7 | + ['Request URL only', [{ url: 'http://example.com' }], { method: 'GET', url: 'http://example.com' }], |
10 | 8 | [ |
11 | 9 | 'Request URL & method only', |
12 | 10 | [{ url: 'http://example.com', method: 'post' }], |
13 | | - { method: 'POST', url: 'http://example.com', body: null }, |
14 | | - ], |
15 | | - [ |
16 | | - 'string URL & options', |
17 | | - ['http://example.com', { method: 'post', body: JSON.stringify(data) }], |
18 | | - { method: 'POST', url: 'http://example.com', body: '{"name":"Test"}' }, |
| 11 | + { method: 'POST', url: 'http://example.com' }, |
19 | 12 | ], |
| 13 | + ['string URL & options', ['http://example.com', { method: 'post' }], { method: 'POST', url: 'http://example.com' }], |
20 | 14 | [ |
21 | 15 | 'URL object & options', |
22 | | - [new URL('http://example.com'), { method: 'post', body: JSON.stringify(data) }], |
23 | | - { method: 'POST', url: 'http://example.com/', body: '{"name":"Test"}' }, |
| 16 | + [new URL('http://example.com'), { method: 'post' }], |
| 17 | + { method: 'POST', url: 'http://example.com/' }, |
24 | 18 | ], |
25 | 19 | [ |
26 | 20 | 'Request URL & options', |
27 | | - [{ url: 'http://example.com' }, { method: 'post', body: JSON.stringify(data) }], |
28 | | - { method: 'POST', url: 'http://example.com', body: '{"name":"Test"}' }, |
| 21 | + [{ url: 'http://example.com' }, { method: 'post' }], |
| 22 | + { method: 'POST', url: 'http://example.com' }, |
29 | 23 | ], |
30 | 24 | ])('%s', (_name, args, expected) => { |
31 | 25 | const actual = parseFetchArgs(args as unknown[]); |
|
0 commit comments