Skip to content

Commit d24f23e

Browse files
committedAug 17, 2021
feat(stream): add unit tests for custom tooltip components
1 parent 3b8fde1 commit d24f23e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed
 

‎packages/stream/tests/Stream.test.tsx

+27-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ it('should render a basic stream chart', () => {
2727
})
2828

2929
describe('layers', () => {
30-
const CustomLayer = () => <g />
31-
3230
it('should support custom layers', () => {
31+
const CustomLayer = () => <g />
32+
3333
const wrapper = mount(
3434
<Stream<TestDatum> {...commonProps} layers={['grid', 'axes', 'layers', CustomLayer]} />
3535
)
@@ -103,6 +103,15 @@ describe('tooltip', () => {
103103
expect(layerData.id).toBe(commonProps.keys[0])
104104
})
105105

106+
it('should allow to use a custom tooltip', () => {
107+
const CustomTooltip = () => <div />
108+
109+
const wrapper = mount(<Stream<TestDatum> {...commonProps} tooltip={CustomTooltip} />)
110+
111+
wrapper.find('StreamLayer').at(0).find('path').simulate('mouseEnter')
112+
expect(wrapper.find(CustomTooltip).exists()).toBe(true)
113+
})
114+
106115
it('should have stack tooltip enabled by default', () => {
107116
const wrapper = mount(<Stream<TestDatum> {...commonProps} />)
108117

@@ -131,6 +140,22 @@ describe('tooltip', () => {
131140
})
132141
})
133142

143+
it('should allow to use a custom stack tooltip', () => {
144+
const CustomStackTooltip = () => <div />
145+
146+
const wrapper = mount(
147+
<Stream<TestDatum> {...commonProps} stackTooltip={CustomStackTooltip} />
148+
)
149+
150+
wrapper
151+
.find('StreamSlices')
152+
.find('StreamSlicesItem')
153+
.at(0)
154+
.find('rect')
155+
.simulate('mouseEnter')
156+
expect(wrapper.find(CustomStackTooltip).exists()).toBe(true)
157+
})
158+
134159
it('should allow to disable stack tooltip', () => {
135160
const wrapper = mount(<Stream<TestDatum> {...commonProps} enableStackTooltip={false} />)
136161

0 commit comments

Comments
 (0)
Please sign in to comment.