@@ -17,7 +17,7 @@ jest.mock('@sentry/utils', () => {
17
17
18
18
describe ( 'defaultRoutingInstrumentation' , ( ) => {
19
19
const mockFinish = jest . fn ( ) ;
20
- const startTransaction = jest . fn ( ) . mockReturnValue ( { finish : mockFinish } ) ;
20
+ const customStartTransaction = jest . fn ( ) . mockReturnValue ( { finish : mockFinish } ) ;
21
21
beforeEach ( ( ) => {
22
22
const dom = new JSDOM ( ) ;
23
23
// @ts -ignore need to override global document
@@ -27,26 +27,26 @@ describe('defaultRoutingInstrumentation', () => {
27
27
// @ts -ignore need to override global document
28
28
global . location = dom . window . location ;
29
29
30
- startTransaction . mockClear ( ) ;
30
+ customStartTransaction . mockClear ( ) ;
31
31
mockFinish . mockClear ( ) ;
32
32
} ) ;
33
33
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 ( startTransaction ) ;
38
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
37
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
38
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
39
39
} ) ;
40
40
41
41
it ( 'starts a pageload transaction' , ( ) => {
42
- defaultRoutingInstrumentation ( startTransaction ) ;
43
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
44
- expect ( startTransaction ) . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'pageload' } ) ;
42
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
43
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
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 ( startTransaction , false ) ;
49
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
48
+ defaultRoutingInstrumentation ( customStartTransaction , false ) ;
49
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 0 ) ;
50
50
} ) ;
51
51
52
52
describe ( 'navigation transaction' , ( ) => {
@@ -56,37 +56,37 @@ describe('defaultRoutingInstrumentation', () => {
56
56
} ) ;
57
57
58
58
it ( 'it is not created automatically' , ( ) => {
59
- defaultRoutingInstrumentation ( startTransaction ) ;
60
- expect ( startTransaction ) . not . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'navigation' } ) ;
59
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
60
+ expect ( customStartTransaction ) . not . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'navigation' } ) ;
61
61
} ) ;
62
62
63
63
it ( 'is created on location change' , ( ) => {
64
- defaultRoutingInstrumentation ( startTransaction ) ;
64
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
65
65
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
66
66
expect ( addInstrumentationHandlerType ) . toBe ( 'history' ) ;
67
67
68
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 2 ) ;
69
- expect ( startTransaction ) . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'navigation' } ) ;
68
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 2 ) ;
69
+ expect ( customStartTransaction ) . toHaveBeenLastCalledWith ( { name : 'blank' , op : 'navigation' } ) ;
70
70
} ) ;
71
71
72
72
it ( 'is not created if startTransactionOnLocationChange is false' , ( ) => {
73
- defaultRoutingInstrumentation ( startTransaction , true , false ) ;
73
+ defaultRoutingInstrumentation ( customStartTransaction , true , false ) ;
74
74
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
75
75
expect ( addInstrumentationHandlerType ) . toBe ( '' ) ;
76
76
77
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
77
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
78
78
} ) ;
79
79
80
80
it ( 'finishes the last active transaction' , ( ) => {
81
- defaultRoutingInstrumentation ( startTransaction ) ;
81
+ defaultRoutingInstrumentation ( 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 ( startTransaction ) ;
89
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
90
90
91
91
expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
92
92
mockChangeHistory ( { to : 'here' , from : 'there' } ) ;
@@ -98,12 +98,12 @@ describe('defaultRoutingInstrumentation', () => {
98
98
} ) ;
99
99
100
100
it ( 'not created if `from` is equal to `to`' , ( ) => {
101
- defaultRoutingInstrumentation ( startTransaction ) ;
101
+ defaultRoutingInstrumentation ( customStartTransaction ) ;
102
102
mockChangeHistory ( { to : 'first/path' , from : 'first/path' } ) ;
103
103
expect ( addInstrumentationHandlerType ) . toBe ( 'history' ) ;
104
104
105
- expect ( startTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
106
- expect ( startTransaction ) . not . toHaveBeenLastCalledWith ( 'navigation' ) ;
105
+ expect ( customStartTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
106
+ expect ( customStartTransaction ) . not . toHaveBeenLastCalledWith ( 'navigation' ) ;
107
107
} ) ;
108
108
} ) ;
109
109
} ) ;
0 commit comments