Skip to content

Commit

Permalink
chore: Improved documentation for assertSegments (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr authored Dec 6, 2024
1 parent 568525a commit 298473c
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/lib/custom-assertions/assert-segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,63 @@
'use strict'

/**
* This function is used to verify that a tree of trace segments matches an
* expected tree of segment names. For example, if the trace looks like (i.e
* the `parent` parameter):
*
* ```js
* {
* name: 'root-segment',
* children: [
* {
* name: 'child 1',
* children: [
* {
* name: 'grandchild 1',
* children: [
* {
* name: 'great-grandchild',
* children: []
* }
* ]
* },
* {
* name: 'grandchild 2',
* children: []
* }
* ]
* },
* {
* name: 'child 2',
* children: []
* }
* ]
* }
* ```
*
* Then the provided `expected` parameter should look like:
*
* ```js
* [
* 'root-segment',
* [
* 'child 1',
* [
* 'grandchild 1',
* ['great-grandchild],
* 'grandchild 2'
* ],
* 'child 2'
* ],
* ]
* ```
*
* Ordering of the elements in the `expected` parameter is significant when
* `options.exact = true`. Regardless of the `exact` value, ordering of elements
* is significant to indicate the nesting order. Any string immediately
* followed by an array of strings indicates that the first string is a parent
* element, and the subsequent array of strings is its child elements.
*
* @param {TraceSegment} parent Parent segment
* @param {Array} expected Array of strings that represent segment names.
* If an item in the array is another array, it
Expand Down

0 comments on commit 298473c

Please sign in to comment.