File tree 1 file changed +13
-1
lines changed
packages/browser/test/unit
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { getReportDialogEndpoint , SDK_VERSION } from '@sentry/core' ;
2
+ import * as utils from '@sentry/utils' ;
2
3
3
4
import type { Event } from '../../src' ;
4
5
import {
@@ -277,7 +278,7 @@ describe('SentryBrowser initialization', () => {
277
278
expect ( sdkData ?. version ) . toBe ( SDK_VERSION ) ;
278
279
} ) ;
279
280
280
- it ( 'uses SDK source from window' , ( ) => {
281
+ it ( 'uses SDK source from window for package name ' , ( ) => {
281
282
global . SENTRY_SDK_SOURCE = 'loader' ;
282
283
init ( { dsn } ) ;
283
284
@@ -287,6 +288,17 @@ describe('SentryBrowser initialization', () => {
287
288
delete global . SENTRY_SDK_SOURCE ;
288
289
} ) ;
289
290
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
+
290
302
it ( 'should set SDK data when instantiating a client directly' , ( ) => {
291
303
const options = getDefaultBrowserClientOptions ( { dsn } ) ;
292
304
const client = new BrowserClient ( options ) ;
You can’t perform that action at this time.
0 commit comments