@@ -24,7 +24,7 @@ describe('`Transaction` class', () => {
2424 expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
2525 } ) ;
2626
27- it ( 'updates transaction metadata with correct variables needed' , ( ) => {
27+ it ( 'updates transaction name changes with correct variables needed' , ( ) => {
2828 const transaction = new Transaction ( { name : 'dogpark' } ) ;
2929 expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
3030
@@ -62,6 +62,64 @@ describe('`Transaction` class', () => {
6262 propagations : 3 ,
6363 } ,
6464 ] ) ;
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+ ] ) ;
65123 } ) ;
66124
67125 describe ( '`setName` method' , ( ) => {
@@ -81,7 +139,7 @@ describe('`Transaction` class', () => {
81139 expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
82140 } ) ;
83141
84- it ( 'updates transaction metadata with correct variables needed' , ( ) => {
142+ it ( 'updates transaction name changes with correct variables needed' , ( ) => {
85143 const transaction = new Transaction ( { name : 'dogpark' } ) ;
86144 expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
87145
0 commit comments