Skip to content

Commit

Permalink
chore(pie): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze authored and plouc committed Jun 3, 2021
1 parent acdfa90 commit 5e9efe2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/pie/tests/Pie.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,41 @@ describe('Pie', () => {
)
})
})

it('should use legend.data if provided', () => {
const wrapper = mount(
<Pie
width={400}
height={400}
data={sampleData}
colors={{ datum: 'data.color' }}
legends={[
{
anchor: 'bottom',
data: sampleData.map((data, index) => ({
...data,
label: `${data.id}.${index}`,
})),
direction: 'row',
itemWidth: 100,
itemHeight: 20,
},
]}
animate={false}
/>
)

const legendItems = wrapper.find('LegendSvgItem')
expect(legendItems).toHaveLength(sampleData.length)

sampleData.forEach((datum, index) => {
const legendItem = legendItems.at(index)
expect(legendItem.text()).toEqual(`${datum.id}.${index}`)
expect(legendItem.find('SymbolSquare').find('rect').prop('fill')).toEqual(
datum.color
)
})
})
})

describe('interactivity', () => {
Expand Down

0 comments on commit 5e9efe2

Please sign in to comment.