@@ -3,29 +3,27 @@ import { getCurrentHub } from '@sentry/core';
33import * as HandleScope from '../../../src/coreHandlers/handleScope' ;
44import { mockSdk } from './../../index' ;
55
6- let mockHandleScope : jest . MockedFunction < typeof HandleScope . handleScope > ;
7-
86jest . useFakeTimers ( ) ;
97
10- beforeAll ( async function ( ) {
11- await mockSdk ( ) ;
12- jest . spyOn ( HandleScope , 'handleScope' ) ;
13- mockHandleScope = HandleScope . handleScope as jest . MockedFunction < typeof HandleScope . handleScope > ;
14-
15- jest . runAllTimers ( ) ;
16- } ) ;
8+ describe ( 'Integration | coreHandlers | handleScope' , ( ) => {
9+ beforeAll ( async function ( ) {
10+ await mockSdk ( ) ;
11+ jest . runAllTimers ( ) ;
12+ } ) ;
1713
18- it ( 'returns a breadcrumb only if last breadcrumb has changed (integration)' , function ( ) {
19- getCurrentHub ( ) . getScope ( ) ?. addBreadcrumb ( { message : 'testing' } ) ;
14+ it ( 'returns a breadcrumb only if last breadcrumb has changed' , function ( ) {
15+ const mockHandleScope = jest . spyOn ( HandleScope , 'handleScope' ) ;
16+ getCurrentHub ( ) . getScope ( ) ?. addBreadcrumb ( { message : 'testing' } ) ;
2017
21- expect ( mockHandleScope ) . toHaveBeenCalledTimes ( 1 ) ;
22- expect ( mockHandleScope ) . toHaveReturnedWith ( expect . objectContaining ( { message : 'testing' } ) ) ;
18+ expect ( mockHandleScope ) . toHaveBeenCalledTimes ( 1 ) ;
19+ expect ( mockHandleScope ) . toHaveReturnedWith ( expect . objectContaining ( { message : 'testing' } ) ) ;
2320
24- mockHandleScope . mockClear ( ) ;
21+ mockHandleScope . mockClear ( ) ;
2522
26- // This will trigger breadcrumb/scope listener, but handleScope should return
27- // null because breadcrumbs has not changed
28- getCurrentHub ( ) . getScope ( ) ?. setUser ( { email :
'[email protected] ' } ) ; 29- expect ( mockHandleScope ) . toHaveBeenCalledTimes ( 1 ) ;
30- expect ( mockHandleScope ) . toHaveReturnedWith ( null ) ;
23+ // This will trigger breadcrumb/scope listener, but handleScope should return
24+ // null because breadcrumbs has not changed
25+ getCurrentHub ( ) . getScope ( ) ?. setUser ( { email :
'[email protected] ' } ) ; 26+ expect ( mockHandleScope ) . toHaveBeenCalledTimes ( 1 ) ;
27+ expect ( mockHandleScope ) . toHaveReturnedWith ( null ) ;
28+ } ) ;
3129} ) ;
0 commit comments