1- import  {  SDK_VERSION  }  from  '@sentry/core' ; 
1+ import  {  getReportDialogEndpoint ,   SDK_VERSION  }  from  '@sentry/core' ; 
22
33import  { 
44  addBreadcrumb , 
2424// eslint-disable-next-line no-var 
2525declare  var  global : any ; 
2626
27+ jest . mock ( '@sentry/core' ,  ( )  =>  { 
28+   const  original  =  jest . requireActual ( '@sentry/core' ) ; 
29+   return  { 
30+     ...original , 
31+     getReportDialogEndpoint : jest . fn ( ) , 
32+   } ; 
33+ } ) ; 
34+ 
2735describe ( 'SentryBrowser' ,  ( )  =>  { 
2836  const  beforeSend  =  jest . fn ( ) ; 
2937
@@ -74,16 +82,14 @@ describe('SentryBrowser', () => {
7482  } ) ; 
7583
7684  describe ( 'showReportDialog' ,  ( )  =>  { 
85+     beforeEach ( ( )  =>  { 
86+       ( getReportDialogEndpoint  as  jest . Mock ) . mockReset ( ) ; 
87+     } ) ; 
88+ 
7789    describe ( 'user' ,  ( )  =>  { 
7890      const  EX_USER  =  {  email : 
'[email protected] '  } ;  7991      const  options  =  getDefaultBrowserClientOptions ( {  dsn } ) ; 
8092      const  client  =  new  BrowserClient ( options ) ; 
81-       const  reportDialogSpy  =  jest . spyOn ( client ,  'showReportDialog' ) ; 
82- 
83-       beforeEach ( ( )  =>  { 
84-         reportDialogSpy . mockReset ( ) ; 
85-       } ) ; 
86- 
8793      it ( 'uses the user on the scope' ,  ( )  =>  { 
8894        configureScope ( scope  =>  { 
8995          scope . setUser ( EX_USER ) ; 
@@ -92,8 +98,11 @@ describe('SentryBrowser', () => {
9298
9399        showReportDialog ( ) ; 
94100
95-         expect ( reportDialogSpy ) . toBeCalled ( ) ; 
96-         expect ( reportDialogSpy . mock . calls [ 0 ] [ 0 ] ! . user ! . email ) . toBe ( EX_USER . email ) ; 
101+         expect ( getReportDialogEndpoint ) . toHaveBeenCalledTimes ( 1 ) ; 
102+         expect ( getReportDialogEndpoint ) . toHaveBeenCalledWith ( 
103+           expect . any ( Object ) , 
104+           expect . objectContaining ( {  user : {  email : EX_USER . email  }  } ) , 
105+         ) ; 
97106      } ) ; 
98107
99108      it ( 'prioritizes options user over scope user' ,  ( )  =>  { 
@@ -105,8 +114,11 @@ describe('SentryBrowser', () => {
105114        const  DIALOG_OPTION_USER  =  {  email : 
'[email protected] '  } ;  106115        showReportDialog ( {  user : DIALOG_OPTION_USER  } ) ; 
107116
108-         expect ( reportDialogSpy ) . toBeCalled ( ) ; 
109-         expect ( reportDialogSpy . mock . calls [ 0 ] [ 0 ] ! . user ! . email ) . toBe ( DIALOG_OPTION_USER . email ) ; 
117+         expect ( getReportDialogEndpoint ) . toHaveBeenCalledTimes ( 1 ) ; 
118+         expect ( getReportDialogEndpoint ) . toHaveBeenCalledWith ( 
119+           expect . any ( Object ) , 
120+           expect . objectContaining ( {  user : {  email : DIALOG_OPTION_USER . email  }  } ) , 
121+         ) ; 
110122      } ) ; 
111123    } ) ; 
112124  } ) ; 
0 commit comments