@@ -5,24 +5,28 @@ import { createReduxEnhancer } from '../src/redux';
55
66const mockAddBreadcrumb = jest . fn ( ) ;
77const mockSetContext = jest . fn ( ) ;
8+ const mockGlobalScopeAddEventProcessor = jest . fn ( ) ;
89
9- jest . mock ( '@sentry/browser ' , ( ) => ( {
10- ...jest . requireActual ( '@sentry/browser ' ) ,
10+ jest . mock ( '@sentry/core ' , ( ) => ( {
11+ ...jest . requireActual ( '@sentry/core ' ) ,
1112 getCurrentScope ( ) {
1213 return {
1314 addBreadcrumb : mockAddBreadcrumb ,
1415 setContext : mockSetContext ,
1516 } ;
1617 } ,
18+ getGlobalScope ( ) {
19+ return {
20+ addEventProcessor : mockGlobalScopeAddEventProcessor ,
21+ } ;
22+ } ,
1723 addEventProcessor : jest . fn ( ) ,
1824} ) ) ;
1925
20- const mockAddEventProcessor = Sentry . addEventProcessor as jest . Mock ;
21-
2226afterEach ( ( ) => {
2327 mockAddBreadcrumb . mockReset ( ) ;
2428 mockSetContext . mockReset ( ) ;
25- mockAddEventProcessor . mockReset ( ) ;
29+ mockGlobalScopeAddEventProcessor . mockReset ( ) ;
2630} ) ;
2731
2832describe ( 'createReduxEnhancer' , ( ) => {
@@ -257,9 +261,9 @@ describe('createReduxEnhancer', () => {
257261
258262 Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
259263
260- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
264+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
261265
262- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
266+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
263267
264268 const mockEvent = {
265269 contexts : {
@@ -306,7 +310,7 @@ describe('createReduxEnhancer', () => {
306310
307311 Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
308312
309- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 0 ) ;
313+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 0 ) ;
310314 } ) ;
311315
312316 it ( 'does not attach when state.type is not redux' , ( ) => {
@@ -318,9 +322,9 @@ describe('createReduxEnhancer', () => {
318322
319323 Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
320324
321- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
325+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
322326
323- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
327+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
324328
325329 const mockEvent = {
326330 contexts : {
@@ -353,9 +357,9 @@ describe('createReduxEnhancer', () => {
353357
354358 Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
355359
356- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
360+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
357361
358- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
362+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
359363
360364 const mockEvent = {
361365 contexts : {
@@ -385,9 +389,9 @@ describe('createReduxEnhancer', () => {
385389
386390 Redux . createStore ( ( state = initialState ) => state , enhancer ) ;
387391
388- expect ( mockAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
392+ expect ( mockGlobalScopeAddEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
389393
390- const callbackFunction = mockAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
394+ const callbackFunction = mockGlobalScopeAddEventProcessor . mock . calls [ 0 ] [ 0 ] ;
391395
392396 const mockEvent = {
393397 type : 'not_redux' ,
0 commit comments