1
1
/* eslint-disable deprecation/deprecation */
2
2
3
- import { getGlobalObject } from '@sentry/utils' ;
3
+ import { GLOBAL_OBJ } from '@sentry/utils' ;
4
4
5
5
import { getCurrentHub , getHubFromCarrier , Hub } from '../src' ;
6
6
7
- const global = getGlobalObject ( ) ;
8
-
9
7
describe ( 'global' , ( ) => {
10
8
test ( 'getGlobalHub' , ( ) => {
11
9
expect ( getCurrentHub ( ) ) . toBeTruthy ( ) ;
12
- expect ( ( global as any ) . __SENTRY__ . hub ) . toBeTruthy ( ) ;
10
+ expect ( GLOBAL_OBJ . __SENTRY__ . hub ) . toBeTruthy ( ) ;
13
11
} ) ;
14
12
15
13
test ( 'getHubFromCarrier' , ( ) => {
@@ -22,22 +20,21 @@ describe('global', () => {
22
20
23
21
test ( 'getGlobalHub' , ( ) => {
24
22
const newestHub = new Hub ( undefined , undefined , 999999 ) ;
25
- ( global as any ) . __SENTRY__ . hub = newestHub ;
23
+ GLOBAL_OBJ . __SENTRY__ . hub = newestHub ;
26
24
expect ( getCurrentHub ( ) ) . toBe ( newestHub ) ;
27
25
} ) ;
28
26
29
27
test ( 'hub extension methods receive correct hub instance' , ( ) => {
30
28
const newestHub = new Hub ( undefined , undefined , 999999 ) ;
31
- ( global as any ) . __SENTRY__ . hub = newestHub ;
29
+ GLOBAL_OBJ . __SENTRY__ . hub = newestHub ;
32
30
const fn = jest . fn ( ) . mockImplementation ( function ( ...args : [ ] ) {
33
31
// @ts -ignore typescript complains that this can be `any`
34
32
expect ( this ) . toBe ( newestHub ) ;
35
33
expect ( args ) . toEqual ( [ 1 , 2 , 3 ] ) ;
36
34
} ) ;
37
- ( global as any ) . __SENTRY__ . extensions = { } ;
38
- ( global as any ) . __SENTRY__ . extensions . testy = fn ;
35
+ GLOBAL_OBJ . __SENTRY__ . extensions = { } ;
36
+ GLOBAL_OBJ . __SENTRY__ . extensions . testy = fn ;
39
37
( getCurrentHub ( ) as any ) . _callExtensionMethod ( 'testy' , 1 , 2 , 3 ) ;
40
38
expect ( fn ) . toBeCalled ( ) ;
41
39
} ) ;
42
- // (global as any).__SENTRY__
43
40
} ) ;
0 commit comments