|
1 | 1 | /* eslint-disable deprecation/deprecation */
|
| 2 | +import { ClientOptions, DsnComponents } from '@sentry/types'; |
2 | 3 | import { makeDsn } from '@sentry/utils';
|
3 | 4 |
|
4 | 5 | import { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from '../../src/api';
|
5 | 6 |
|
6 | 7 | const ingestDsn = 'https://[email protected]:1234/subpath/123';
|
7 | 8 | const dsnPublic = 'https://[email protected]:1234/subpath/123';
|
8 | 9 | const tunnel = 'https://hello.com/world';
|
| 10 | +const _metadata = { sdk: { name: 'sentry.javascript.browser', version: '12.31.12' } } as ClientOptions['_metadata']; |
9 | 11 |
|
10 | 12 | const dsnPublicComponents = makeDsn(dsnPublic);
|
11 | 13 |
|
12 | 14 | describe('API', () => {
|
13 |
| - test('getEnvelopeEndpoint', () => { |
14 |
| - expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicComponents)).toEqual( |
15 |
| - 'https://sentry.io:1234/subpath/api/123/envelope/?sentry_key=abc&sentry_version=7', |
| 15 | + describe('getEnvelopeEndpointWithUrlEncodedAuth', () => { |
| 16 | + it.each([ |
| 17 | + [ |
| 18 | + "doesn't include `sentry_client` when called with only DSN", |
| 19 | + dsnPublicComponents, |
| 20 | + undefined, |
| 21 | + 'https://sentry.io:1234/subpath/api/123/envelope/?sentry_key=abc&sentry_version=7', |
| 22 | + ], |
| 23 | + ['uses `tunnel` value when called with `tunnel` as string', dsnPublicComponents, tunnel, tunnel], |
| 24 | + [ |
| 25 | + 'uses `tunnel` value when called with `tunnel` in options', |
| 26 | + dsnPublicComponents, |
| 27 | + { tunnel } as ClientOptions, |
| 28 | + tunnel, |
| 29 | + ], |
| 30 | + [ |
| 31 | + 'uses `tunnel` value when called with `tunnel` and `_metadata` in options', |
| 32 | + dsnPublicComponents, |
| 33 | + { tunnel, _metadata } as ClientOptions, |
| 34 | + tunnel, |
| 35 | + ], |
| 36 | + [ |
| 37 | + 'includes `sentry_client` when called with `_metadata` in options and no tunnel', |
| 38 | + dsnPublicComponents, |
| 39 | + { _metadata } as ClientOptions, |
| 40 | + 'https://sentry.io:1234/subpath/api/123/envelope/?sentry_key=abc&sentry_version=7&sentry_client=sentry.javascript.browser%2F12.31.12', |
| 41 | + ], |
| 42 | + ])( |
| 43 | + '%s', |
| 44 | + ( |
| 45 | + _testName: string, |
| 46 | + dsnComponents: DsnComponents, |
| 47 | + tunnelOrOptions: string | ClientOptions | undefined, |
| 48 | + expected: string, |
| 49 | + ) => { |
| 50 | + expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnComponents, tunnelOrOptions)).toBe(expected); |
| 51 | + }, |
16 | 52 | );
|
17 |
| - expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicComponents, tunnel)).toEqual(tunnel); |
18 | 53 | });
|
19 | 54 |
|
20 | 55 | describe('getReportDialogEndpoint', () => {
|
|
0 commit comments