@@ -24,6 +24,46 @@ describe('`Transaction` class', () => {
24
24
expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
25
25
} ) ;
26
26
27
+ it ( 'updates transaction metadata with correct variables needed' , ( ) => {
28
+ const transaction = new Transaction ( { name : 'dogpark' } ) ;
29
+ expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
30
+
31
+ transaction . name = 'ballpit' ;
32
+
33
+ expect ( transaction . metadata . changes ) . toEqual ( [
34
+ {
35
+ source : 'custom' ,
36
+ timestamp : expect . any ( Number ) ,
37
+ propagations : 0 ,
38
+ } ,
39
+ ] ) ;
40
+
41
+ transaction . metadata . propagations += 3 ;
42
+
43
+ expect ( transaction . metadata . changes ) . toEqual ( [
44
+ {
45
+ source : 'custom' ,
46
+ timestamp : expect . any ( Number ) ,
47
+ propagations : 0 ,
48
+ } ,
49
+ ] ) ;
50
+
51
+ transaction . name = 'playground' ;
52
+
53
+ expect ( transaction . metadata . changes ) . toEqual ( [
54
+ {
55
+ source : 'custom' ,
56
+ timestamp : expect . any ( Number ) ,
57
+ propagations : 0 ,
58
+ } ,
59
+ {
60
+ source : 'custom' ,
61
+ timestamp : expect . any ( Number ) ,
62
+ propagations : 3 ,
63
+ } ,
64
+ ] ) ;
65
+ } ) ;
66
+
27
67
describe ( '`setName` method' , ( ) => {
28
68
it ( "sets source to `'custom'` if no source provided" , ( ) => {
29
69
const transaction = new Transaction ( { name : 'dogpark' } ) ;
@@ -40,6 +80,46 @@ describe('`Transaction` class', () => {
40
80
expect ( transaction . name ) . toEqual ( 'ballpit' ) ;
41
81
expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
42
82
} ) ;
83
+
84
+ it ( 'updates transaction metadata with correct variables needed' , ( ) => {
85
+ const transaction = new Transaction ( { name : 'dogpark' } ) ;
86
+ expect ( transaction . metadata . changes ) . toEqual ( [ ] ) ;
87
+
88
+ transaction . name = 'ballpit' ;
89
+
90
+ expect ( transaction . metadata . changes ) . toEqual ( [
91
+ {
92
+ source : 'custom' ,
93
+ timestamp : expect . any ( Number ) ,
94
+ propagations : 0 ,
95
+ } ,
96
+ ] ) ;
97
+
98
+ transaction . metadata . propagations += 3 ;
99
+
100
+ expect ( transaction . metadata . changes ) . toEqual ( [
101
+ {
102
+ source : 'custom' ,
103
+ timestamp : expect . any ( Number ) ,
104
+ propagations : 0 ,
105
+ } ,
106
+ ] ) ;
107
+
108
+ transaction . setName ( 'playground' , 'task' ) ;
109
+
110
+ expect ( transaction . metadata . changes ) . toEqual ( [
111
+ {
112
+ source : 'custom' ,
113
+ timestamp : expect . any ( Number ) ,
114
+ propagations : 0 ,
115
+ } ,
116
+ {
117
+ source : 'task' ,
118
+ timestamp : expect . any ( Number ) ,
119
+ propagations : 3 ,
120
+ } ,
121
+ ] ) ;
122
+ } ) ;
43
123
} ) ;
44
124
} ) ;
45
125
} ) ;
0 commit comments