1
1
import { JSDOM } from 'jsdom' ;
2
2
3
- import { defaultRoutingInstrumentation } from '../../src/browser/router' ;
3
+ import { instrumentRoutingWithDefaults } from '../../src/browser/router' ;
4
4
5
5
let mockChangeHistory : ( { to, from } : { to : string ; from ?: string } ) => void = ( ) => undefined ;
6
6
let addInstrumentationHandlerType : string = '' ;
@@ -15,7 +15,7 @@ jest.mock('@sentry/utils', () => {
15
15
} ;
16
16
} ) ;
17
17
18
- describe ( 'defaultRoutingInstrumentation ' , ( ) => {
18
+ describe ( 'instrumentRoutingWithDefaults ' , ( ) => {
19
19
const mockFinish = jest . fn ( ) ;
20
20
const customStartTransaction = jest . fn ( ) . mockReturnValue ( { finish : mockFinish } ) ;
21
21
beforeEach ( ( ) => {
@@ -34,18 +34,18 @@ describe('defaultRoutingInstrumentation', () => {
34
34
it ( 'does not start transactions if global location is undefined' , ( ) => {
35
35
// @ts -ignore need to override global document
36
36
global . location = undefined ;
37
- defaultRoutingInstrumentation ( customStartTransaction ) ;
37
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
38
38
expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
39
39
} ) ;
40
40
41
41
it ( 'starts a pageload transaction' , ( ) => {
42
- defaultRoutingInstrumentation ( customStartTransaction ) ;
42
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
43
43
expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
44
44
expect ( customStartTransaction ) . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'pageload' } ) ;
45
45
} ) ;
46
46
47
47
it ( 'does not start a pageload transaction if startTransactionOnPageLoad is false' , ( ) => {
48
- defaultRoutingInstrumentation ( customStartTransaction , false ) ;
48
+ instrumentRoutingWithDefaults ( customStartTransaction , false ) ;
49
49
expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
50
50
} ) ;
51
51
@@ -56,12 +56,12 @@ describe('defaultRoutingInstrumentation', () => {
56
56
} ) ;
57
57
58
58
it ( 'it is not created automatically' , ( ) => {
59
- defaultRoutingInstrumentation ( customStartTransaction ) ;
59
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
60
60
expect ( customStartTransaction ) . not . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'navigation' } ) ;
61
61
} ) ;
62
62
63
63
it ( 'is created on location change' , ( ) => {
64
- defaultRoutingInstrumentation ( customStartTransaction ) ;
64
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
65
65
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
66
66
expect ( addInstrumentationHandlerType ) . toBe ( 'history' ) ;
67
67
@@ -70,23 +70,23 @@ describe('defaultRoutingInstrumentation', () => {
70
70
} ) ;
71
71
72
72
it ( 'is not created if startTransactionOnLocationChange is false' , ( ) => {
73
- defaultRoutingInstrumentation ( customStartTransaction , true , false ) ;
73
+ instrumentRoutingWithDefaults ( customStartTransaction , true , false ) ;
74
74
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
75
75
expect ( addInstrumentationHandlerType ) . toBe ( '' ) ;
76
76
77
77
expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
78
78
} ) ;
79
79
80
80
it ( 'finishes the last active transaction' , ( ) => {
81
- defaultRoutingInstrumentation ( customStartTransaction ) ;
81
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
82
82
83
83
expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
84
84
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
85
85
expect ( mockFinish ) . toHaveBeenCalledTimes ( 1 ) ;
86
86
} ) ;
87
87
88
88
it ( 'will finish active transaction multiple times' , ( ) => {
89
- defaultRoutingInstrumentation ( customStartTransaction ) ;
89
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
90
90
91
91
expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
92
92
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
@@ -98,7 +98,7 @@ describe('defaultRoutingInstrumentation', () => {
98
98
} ) ;
99
99
100
100
it ( 'not created if `from` is equal to `to`' , ( ) => {
101
- defaultRoutingInstrumentation ( customStartTransaction ) ;
101
+ instrumentRoutingWithDefaults ( customStartTransaction ) ;
102
102
mockChangeHistory ( { to : 'first/path' , from : 'first/path' } ) ;
103
103
expect ( addInstrumentationHandlerType ) . toBe ( 'history' ) ;
104
104
0 commit comments