44 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
55 SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ,
66 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
7+ spanToJSON ,
78} from '@sentry/core' ;
89
910import { Transaction , addExtensionMethods } from '../src' ;
@@ -21,23 +22,23 @@ describe('`Transaction` class', () => {
2122 attributes : { [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' } ,
2223 } ) ;
2324
24- expect ( transaction . name ) . toEqual ( 'dogpark' ) ;
25- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toEqual ( 'route' ) ;
25+ expect ( spanToJSON ( transaction ) . description ) . toEqual ( 'dogpark' ) ;
26+ expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
2627 } ) ;
2728
2829 it ( "sets source to be `'custom'` in constructor if not provided" , ( ) => {
2930 const transaction = new Transaction ( { name : 'dogpark' } ) ;
3031
31- expect ( transaction . name ) . toEqual ( 'dogpark' ) ;
32- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toBe ( 'custom' ) ;
32+ expect ( spanToJSON ( transaction ) . description ) . toEqual ( 'dogpark' ) ;
33+ expect ( transaction . metadata . source ) . toBe ( 'custom' ) ;
3334 } ) ;
3435
3536 it ( "sets source to `'custom'` when assigning to `name` property" , ( ) => {
3637 const transaction = new Transaction ( { name : 'dogpark' } ) ;
37- transaction . name = 'ballpit' ;
38+ transaction . updateName ( 'ballpit' ) ;
3839
39- expect ( transaction . name ) . toEqual ( 'ballpit' ) ;
40- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toEqual ( 'custom' ) ;
40+ expect ( spanToJSON ( transaction ) . description ) . toEqual ( 'ballpit' ) ;
41+ expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
4142 } ) ;
4243
4344 it ( 'sets instrumenter to be `sentry` in constructor if not provided' , ( ) => {
@@ -52,32 +53,22 @@ describe('`Transaction` class', () => {
5253 expect ( transaction . instrumenter ) . toEqual ( 'otel' ) ;
5354 } ) ;
5455
55- describe ( '`setName ` method' , ( ) => {
56+ describe ( '`updateName ` method' , ( ) => {
5657 it ( "sets source to `'custom'` if no source provided" , ( ) => {
5758 const transaction = new Transaction ( { name : 'dogpark' } ) ;
5859 transaction . updateName ( 'ballpit' ) ;
5960
60- expect ( transaction . name ) . toEqual ( 'ballpit' ) ;
61- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toEqual ( 'custom' ) ;
61+ expect ( spanToJSON ( transaction ) . description ) . toEqual ( 'ballpit' ) ;
62+ expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
6263 } ) ;
6364
6465 it ( 'uses given `source` value' , ( ) => {
6566 const transaction = new Transaction ( { name : 'dogpark' } ) ;
66- transaction . updateName ( 'ballpit' , 'route' ) ;
67-
68- expect ( transaction . name ) . toEqual ( 'ballpit' ) ;
69- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toEqual ( 'route' ) ;
70- } ) ;
71- } ) ;
72-
73- describe ( '`updateName` method' , ( ) => {
74- it ( 'does not change the source' , ( ) => {
75- const transaction = new Transaction ( { name : 'dogpark' } ) ;
76- transaction . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
7767 transaction . updateName ( 'ballpit' ) ;
68+ transaction . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
7869
79- expect ( transaction . name ) . toEqual ( 'ballpit' ) ;
80- expect ( transaction . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] ) . toEqual ( 'route' ) ;
70+ expect ( spanToJSON ( transaction ) . description ) . toEqual ( 'ballpit' ) ;
71+ expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
8172 } ) ;
8273 } ) ;
8374 } ) ;
0 commit comments