Skip to content

Commit 0156614

Browse files
committed
more tests
1 parent 931a81e commit 0156614

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/browser/test/unit/index.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getReportDialogEndpoint, SDK_VERSION } from '@sentry/core';
2+
import * as utils from '@sentry/utils';
23

34
import type { Event } from '../../src';
45
import {
@@ -277,7 +278,7 @@ describe('SentryBrowser initialization', () => {
277278
expect(sdkData?.version).toBe(SDK_VERSION);
278279
});
279280

280-
it('uses SDK source from window', () => {
281+
it('uses SDK source from window for package name', () => {
281282
global.SENTRY_SDK_SOURCE = 'loader';
282283
init({ dsn });
283284

@@ -287,6 +288,17 @@ describe('SentryBrowser initialization', () => {
287288
delete global.SENTRY_SDK_SOURCE;
288289
});
289290

291+
it('uses SDK source from global for package name', () => {
292+
const spy = jest.spyOn(utils, 'getSDKSource').mockReturnValue('cdn');
293+
init({ dsn });
294+
295+
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata.sdk;
296+
297+
expect(sdkData?.packages[0].name).toBe('cdn:@sentry/browser');
298+
expect(utils.getSDKSource).toBeCalledTimes(1);
299+
spy.mockRestore();
300+
});
301+
290302
it('should set SDK data when instantiating a client directly', () => {
291303
const options = getDefaultBrowserClientOptions({ dsn });
292304
const client = new BrowserClient(options);

0 commit comments

Comments
 (0)