Skip to content

Commit

Permalink
Fixed unit tests not using full objects
Browse files Browse the repository at this point in the history
  • Loading branch information
supermar1010 committed Dec 19, 2024
1 parent 586f1fd commit c1861f4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/__tests__/heatmaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,24 @@ describe('heatmaps', () => {
})

it('should ignore clicks if they come from the toolbar', async () => {
const testElementToolbar = document.createElement('div')
testElementToolbar.id = '__POSTHOG_TOOLBAR__'

posthog.heatmaps?.['_onClick']?.(
createMockMouseEvent({
target: { id: '__POSTHOG_TOOLBAR__' } as Element,
target: testElementToolbar,
})
)
expect(posthog.heatmaps?.['buffer']).toEqual(undefined)

const testElementClosest = document.createElement('div')
testElementClosest.closest = () => {
return {}
}

posthog.heatmaps?.['_onClick']?.(
createMockMouseEvent({
target: { closest: () => ({}) } as unknown as Element,
target: testElementClosest,
})
)
expect(posthog.heatmaps?.['buffer']).toEqual(undefined)
Expand Down

0 comments on commit c1861f4

Please sign in to comment.