Skip to content

Commit

Permalink
test: Mock d3 within UI unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Jul 17, 2023
1 parent 3d6ecc2 commit fedd542
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ui/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import React from 'react'

configure({ testIdAttribute: 'data-test' })

// TODO: Remove once we have a proper solution for mocking d3.
jest.mock('d3', () => ({
extent: () => '',
scaleOrdinal: () => ({ domain: () => ({ range: () => '' }) }),
arc: () => '',
pie: () => ({ value: () => () => [] }),
}))
jest.mock('d3-interpolate', () => ({ extent: () => '' }))

const icons = Object.entries(Icons).reduce((acc, [iconName, iconComponent]) => {
if ('displayName' in iconComponent) acc[iconName.slice(0, -4)] = React.createElement(iconComponent as React.FC)
return acc
Expand Down

0 comments on commit fedd542

Please sign in to comment.