Skip to content

Commit

Permalink
Add tests for populated and unpopulated arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
davemurphysf committed Nov 7, 2023
1 parent 80f2551 commit b279c3a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/__tests__/autocapture-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
isAngularStyleAttr,
getNestedSpanText,
getDirectAndNestedSpanText,
getElementsChainString,
} from '../autocapture-utils'

describe(`Autocapture utility functions`, () => {
Expand Down Expand Up @@ -397,4 +398,19 @@ describe(`Autocapture utility functions`, () => {
expect(getNestedSpanText(parent)).toBe('test test2')
})
})

describe('getElementsChainString', () => {
it('should return an empty string with no elements', () => {
const elementChain = getElementsChainString([])

expect(elementChain).toEqual('')
})
it('should process elements correctly', () => {
const elementChain = getElementsChainString([
{ tag_name: 'div', nth_child: 1, nth_of_type: 2, $el_text: 'text' },
])

expect(elementChain).toEqual('div:nth-child="1"nth-of-type="2"text="text"')
})
})
})

0 comments on commit b279c3a

Please sign in to comment.