@@ -154,11 +154,25 @@ describe('Tracer integration tests', () => {
154
154
// Assert that there are three subsegments
155
155
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
156
156
157
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
158
- // Assert that the subsegment names are the expected ones
159
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
160
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
161
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
157
+ // Sort the subsegments by name
158
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
159
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
160
+ const otherSegments : ParsedDocument [ ] = [ ] ;
161
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
162
+ if ( subsegment . name === 'DynamoDB' ) {
163
+ dynamoDBSubsegments . push ( subsegment ) ;
164
+ } else if ( subsegment . name === 'httpbin.org' ) {
165
+ httpSubsegment . push ( subsegment ) ;
166
+ } else {
167
+ otherSegments . push ( subsegment ) ;
168
+ }
169
+ } ) ;
170
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
171
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
172
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
173
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
174
+ // Assert that there are exactly zero other subsegments
175
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
162
176
163
177
const { annotations, metadata } = handlerSubsegment ;
164
178
@@ -225,11 +239,25 @@ describe('Tracer integration tests', () => {
225
239
// Assert that there're two subsegments
226
240
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
227
241
228
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
229
- // Assert that the subsegment names is the expected ones
230
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
231
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
232
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
242
+ // Sort the subsegments by name
243
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
244
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
245
+ const otherSegments : ParsedDocument [ ] = [ ] ;
246
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
247
+ if ( subsegment . name === 'DynamoDB' ) {
248
+ dynamoDBSubsegments . push ( subsegment ) ;
249
+ } else if ( subsegment . name === 'httpbin.org' ) {
250
+ httpSubsegment . push ( subsegment ) ;
251
+ } else {
252
+ otherSegments . push ( subsegment ) ;
253
+ }
254
+ } ) ;
255
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
256
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
257
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
258
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
259
+ // Assert that there are exactly zero other subsegments
260
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
233
261
234
262
const { annotations, metadata } = handlerSubsegment ;
235
263
@@ -296,11 +324,25 @@ describe('Tracer integration tests', () => {
296
324
// Assert that there're two subsegments
297
325
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 3 ) ;
298
326
299
- const [ AWSSDKSubsegment1 , AWSSDKSubsegment2 , HTTPSegment ] = handlerSubsegment ?. subsegments ;
300
- // Assert that the subsegment names are the expected ones
301
- expect ( AWSSDKSubsegment1 . name ) . toBe ( 'DynamoDB' ) ;
302
- expect ( AWSSDKSubsegment2 . name ) . toBe ( 'DynamoDB' ) ;
303
- expect ( HTTPSegment . name ) . toBe ( 'httpbin.org' ) ;
327
+ // Sort the subsegments by name
328
+ const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
329
+ const httpSubsegment : ParsedDocument [ ] = [ ] ;
330
+ const otherSegments : ParsedDocument [ ] = [ ] ;
331
+ handlerSubsegment ?. subsegments . forEach ( subsegment => {
332
+ if ( subsegment . name === 'DynamoDB' ) {
333
+ dynamoDBSubsegments . push ( subsegment ) ;
334
+ } else if ( subsegment . name === 'httpbin.org' ) {
335
+ httpSubsegment . push ( subsegment ) ;
336
+ } else {
337
+ otherSegments . push ( subsegment ) ;
338
+ }
339
+ } ) ;
340
+ // Assert that there are exactly two subsegment with the name 'DynamoDB'
341
+ expect ( dynamoDBSubsegments . length ) . toBe ( 2 ) ;
342
+ // Assert that there is exactly one subsegment with the name 'httpbin.org'
343
+ expect ( httpSubsegment . length ) . toBe ( 1 ) ;
344
+ // Assert that there are exactly zero other subsegments
345
+ expect ( otherSegments . length ) . toBe ( 0 ) ;
304
346
305
347
const { annotations, metadata } = handlerSubsegment ;
306
348
@@ -387,7 +429,7 @@ describe('Tracer integration tests', () => {
387
429
// Assert that the subsegment name is the expected one
388
430
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
389
431
if ( handlerSubsegment ?. subsegments !== undefined ) {
390
- // Assert that there're three subsegments
432
+ // Assert that there are four subsegments
391
433
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
392
434
393
435
// Sort the subsegments by name
@@ -489,7 +531,7 @@ describe('Tracer integration tests', () => {
489
531
// Assert that the subsegment name is the expected one
490
532
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
491
533
if ( handlerSubsegment ?. subsegments !== undefined ) {
492
- // Assert that there're three subsegments
534
+ // Assert that there are four subsegments
493
535
expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
494
536
495
537
// Sort the subsegments by name
@@ -591,8 +633,8 @@ describe('Tracer integration tests', () => {
591
633
// Assert that the subsegment name is the expected one
592
634
expect ( handlerSubsegment . name ) . toBe ( '## index.handler' ) ;
593
635
if ( handlerSubsegment ?. subsegments !== undefined ) {
594
- // Assert that there're three subsegments
595
- expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 5 ) ;
636
+ // Assert that there are four subsegments
637
+ expect ( handlerSubsegment ?. subsegments ?. length ) . toBe ( 4 ) ;
596
638
597
639
// Sort the subsegments by name
598
640
const dynamoDBSubsegments : ParsedDocument [ ] = [ ] ;
0 commit comments