@@ -5,24 +5,28 @@ import { createReduxEnhancer } from '../src/redux';
5
5
6
6
const mockAddBreadcrumb = jest . fn ( ) ;
7
7
const mockSetContext = jest . fn ( ) ;
8
+ const mockGlobalScopeAddEventProcessor = jest . fn ( ) ;
8
9
9
- jest . mock ( '@sentry/browser ' , ( ) => ( {
10
- ...jest . requireActual ( '@sentry/browser ' ) ,
10
+ jest . mock ( '@sentry/core ' , ( ) => ( {
11
+ ...jest . requireActual ( '@sentry/core ' ) ,
11
12
getCurrentScope ( ) {
12
13
return {
13
14
addBreadcrumb : mockAddBreadcrumb ,
14
15
setContext : mockSetContext ,
15
16
} ;
16
17
} ,
18
+ getGlobalScope ( ) {
19
+ return {
20
+ addEventProcessor : mockGlobalScopeAddEventProcessor ,
21
+ } ;
22
+ } ,
17
23
addEventProcessor : jest . fn ( ) ,
18
24
} ) ) ;
19
25
20
- const mockAddEventProcessor = Sentry . addEventProcessor as jest . Mock ;
21
-
22
26
afterEach ( ( ) => {
23
27
mockAddBreadcrumb . mockReset ( ) ;
24
28
mockSetContext . mockReset ( ) ;
25
- mockAddEventProcessor . mockReset ( ) ;
29
+ mockGlobalScopeAddEventProcessor . mockReset ( ) ;
26
30
} ) ;
27
31
28
32
describe ( 'createReduxEnhancer' , ( ) => {
@@ -257,9 +261,9 @@ describe('createReduxEnhancer', () => {
257
261
258
262
Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
259
263
260
- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
264
+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
261
265
262
- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
266
+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
263
267
264
268
const mockEvent = {
265
269
contexts : {
@@ -306,7 +310,7 @@ describe('createReduxEnhancer', () => {
306
310
307
311
Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
308
312
309
- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 0 ) ;
313
+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 0 ) ;
310
314
} ) ;
311
315
312
316
it ( 'does not attach when state.type is not redux' , ( ) => {
@@ -318,9 +322,9 @@ describe('createReduxEnhancer', () => {
318
322
319
323
Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
320
324
321
- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
325
+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
322
326
323
- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
327
+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
324
328
325
329
const mockEvent = {
326
330
contexts : {
@@ -353,9 +357,9 @@ describe('createReduxEnhancer', () => {
353
357
354
358
Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
355
359
356
- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
360
+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
357
361
358
- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
362
+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
359
363
360
364
const mockEvent = {
361
365
contexts : {
@@ -385,9 +389,9 @@ describe('createReduxEnhancer', () => {
385
389
386
390
Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
387
391
388
- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
392
+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
389
393
390
- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
394
+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
391
395
392
396
const mockEvent = {
393
397
type : 'not_redux' ,
0 commit comments