Skip to content

Commit a0d3b86

Browse files
committedAug 28, 2021
feat(scatterplot): add unit tests for annotations
1 parent 8afb16a commit a0d3b86

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed
 

‎packages/scatterplot/tests/ScatterPlot.test.tsx

+34-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,40 @@ describe('event handlers', () => {
389389
})
390390

391391
describe('annotations', () => {
392-
it('should support annotations', () => {})
392+
it('should support annotations', () => {
393+
const wrapper = mount(
394+
<ScatterPlot<TestDatum>
395+
{...baseProps}
396+
layers={['nodes', 'annotations']}
397+
isInteractive={false}
398+
annotations={[
399+
{
400+
match: d => d.index === 2,
401+
type: 'circle',
402+
note: 'annotation',
403+
noteX: 350,
404+
noteY: 50,
405+
},
406+
]}
407+
/>
408+
)
409+
410+
const annotation = wrapper.find('Annotation')
411+
expect(annotation.exists()).toBe(true)
412+
413+
const node = wrapper.find('Node').at(2)
414+
415+
expect(annotation.prop('datum')).toBe(node.prop('node'))
416+
expect(annotation.prop('x')).toBe(node.prop<ScatterPlotNodeData<TestDatum>>('node').x)
417+
expect(annotation.prop('y')).toBe(node.prop<ScatterPlotNodeData<TestDatum>>('node').y)
418+
expect(annotation.prop('size')).toBe(node.prop<ScatterPlotNodeData<TestDatum>>('node').size)
419+
expect(annotation.prop('width')).toBe(
420+
node.prop<ScatterPlotNodeData<TestDatum>>('node').size
421+
)
422+
expect(annotation.prop('height')).toBe(
423+
node.prop<ScatterPlotNodeData<TestDatum>>('node').size
424+
)
425+
})
393426

394427
it('should support markers', () => {
395428
const wrapper = mount(

0 commit comments

Comments
 (0)
Please sign in to comment.