@@ -24,7 +24,7 @@ describe('`Transaction` class', () => {
24
24
expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
25
25
} ) ;
26
26
27
- it ( 'updates transaction metadata with correct variables needed' , ( ) => {
27
+ it ( 'updates transaction name changes with correct variables needed' , ( ) => {
28
28
const transaction = new Transaction ( { name : 'dogpark' } ) ;
29
29
expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
30
30
@@ -62,6 +62,64 @@ describe('`Transaction` class', () => {
62
62
propagations : 3 ,
63
63
} ,
64
64
] ) ;
65
+
66
+ // Only change `source`
67
+ transaction . setName ( 'playground' , 'route' ) ;
68
+
69
+ expect ( transaction . metadata . changes ) . toEqual ( [
70
+ {
71
+ source : 'custom' ,
72
+ timestamp : expect . any ( Number ) ,
73
+ propagations : 0 ,
74
+ } ,
75
+ {
76
+ source : 'custom' ,
77
+ timestamp : expect . any ( Number ) ,
78
+ propagations : 3 ,
79
+ } ,
80
+ {
81
+ source : 'route' ,
82
+ timestamp : expect . any ( Number ) ,
83
+ propagations : 3 ,
84
+ } ,
85
+ ] ) ;
86
+ } ) ;
87
+
88
+ it ( "doesn't update transaction name changes if no change in data" , ( ) => {
89
+ const transaction = new Transaction ( { name : 'dogpark' } ) ;
90
+ expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
91
+
92
+ transaction . name = 'ballpit' ;
93
+
94
+ expect ( transaction . metadata . changes ) . toEqual ( [
95
+ {
96
+ source : 'custom' ,
97
+ timestamp : expect . any ( Number ) ,
98
+ propagations : 0 ,
99
+ } ,
100
+ ] ) ;
101
+
102
+ transaction . name = 'ballpit' ;
103
+
104
+ // Still only one entry
105
+ expect ( transaction . metadata . changes ) . toEqual ( [
106
+ {
107
+ source : 'custom' ,
108
+ timestamp : expect . any ( Number ) ,
109
+ propagations : 0 ,
110
+ } ,
111
+ ] ) ;
112
+
113
+ transaction . setName ( 'ballpit' , 'custom' ) ;
114
+
115
+ // Still only one entry
116
+ expect ( transaction . metadata . changes ) . toEqual ( [
117
+ {
118
+ source : 'custom' ,
119
+ timestamp : expect . any ( Number ) ,
120
+ propagations : 0 ,
121
+ } ,
122
+ ] ) ;
65
123
} ) ;
66
124
67
125
describe ( '`setName` method' , ( ) => {
@@ -81,7 +139,7 @@ describe('`Transaction` class', () => {
81
139
expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
82
140
} ) ;
83
141
84
- it ( 'updates transaction metadata with correct variables needed' , ( ) => {
142
+ it ( 'updates transaction name changes with correct variables needed' , ( ) => {
85
143
const transaction = new Transaction ( { name : 'dogpark' } ) ;
86
144
expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
87
145
0 commit comments