@@ -151,11 +151,25 @@ describe('Tracer integration tests', () => {
151
151
// Assert that there are three subsegments
152
152
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
153
153
154
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
155
- // Assert that the subsegment names are the expected ones
156
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
157
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
158
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
154
+ // Sort the subsegments by name
155
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
156
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
157
+ const otherSegments : ParsedDocument [ ] = [ ] ;
158
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
159
+ if ( subsegment . name === 'DynamoDB' ) {
160
+ dynamoDBSubsegments . push ( subsegment ) ;
161
+ } else if ( subsegment . name === 'httpbin.org' ) {
162
+ httpSubsegment . push ( subsegment ) ;
163
+ } else {
164
+ otherSegments . push ( subsegment ) ;
165
+ }
166
+ } ) ;
167
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
168
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
169
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
170
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
171
+ // Assert that there are exactly zero other subsegments
172
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
159
173
160
174
const { annotations, metadata } = handlerSubsegment ;
161
175
@@ -222,11 +236,25 @@ describe('Tracer integration tests', () => {
222
236
// Assert that there're two subsegments
223
237
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
224
238
225
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
226
- // Assert that the subsegment names is the expected ones
227
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
228
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
229
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
239
+ // Sort the subsegments by name
240
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
241
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
242
+ const otherSegments : ParsedDocument [ ] = [ ] ;
243
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
244
+ if ( subsegment . name === 'DynamoDB' ) {
245
+ dynamoDBSubsegments . push ( subsegment ) ;
246
+ } else if ( subsegment . name === 'httpbin.org' ) {
247
+ httpSubsegment . push ( subsegment ) ;
248
+ } else {
249
+ otherSegments . push ( subsegment ) ;
250
+ }
251
+ } ) ;
252
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
253
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
254
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
255
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
256
+ // Assert that there are exactly zero other subsegments
257
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
230
258
231
259
const { annotations, metadata } = handlerSubsegment ;
232
260
@@ -293,11 +321,25 @@ describe('Tracer integration tests', () => {
293
321
// Assert that there're two subsegments
294
322
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
295
323
296
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
297
- // Assert that the subsegment names are the expected ones
298
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
299
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
300
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
324
+ // Sort the subsegments by name
325
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
326
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
327
+ const otherSegments : ParsedDocument [ ] = [ ] ;
328
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
329
+ if ( subsegment . name === 'DynamoDB' ) {
330
+ dynamoDBSubsegments . push ( subsegment ) ;
331
+ } else if ( subsegment . name === 'httpbin.org' ) {
332
+ httpSubsegment . push ( subsegment ) ;
333
+ } else {
334
+ otherSegments . push ( subsegment ) ;
335
+ }
336
+ } ) ;
337
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
338
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
339
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
340
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
341
+ // Assert that there are exactly zero other subsegments
342
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
301
343
302
344
const { annotations, metadata } = handlerSubsegment ;
303
345
@@ -384,7 +426,7 @@ describe('Tracer integration tests', () => {
384
426
// Assert that the subsegment name is the expected one
385
427
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
386
428
if ( handlerSubsegment ?. subsegments !== undefined ) {
387
- // Assert that there're three subsegments
429
+ // Assert that there are four subsegments
388
430
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
389
431
390
432
// Sort the subsegments by name
@@ -486,7 +528,7 @@ describe('Tracer integration tests', () => {
486
528
// Assert that the subsegment name is the expected one
487
529
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
488
530
if ( handlerSubsegment ?. subsegments !== undefined ) {
489
- // Assert that there're three subsegments
531
+ // Assert that there are four subsegments
490
532
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
491
533
492
534
// Sort the subsegments by name
@@ -588,8 +630,8 @@ describe('Tracer integration tests', () => {
588
630
// Assert that the subsegment name is the expected one
589
631
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
590
632
if ( handlerSubsegment ?. subsegments !== undefined ) {
591
- // Assert that there're three subsegments
592
- expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 5 ) ;
633
+ // Assert that there are four subsegments
634
+ expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
593
635
594
636
// Sort the subsegments by name
595
637
const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
0 commit comments