Skip to content

Commit

Permalink
fix(swarmplot): get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 22, 2021
1 parent 9b1f12c commit b7aa6c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
26 changes: 9 additions & 17 deletions packages/swarmplot/src/CircleSvg.tsx
Expand Up @@ -6,19 +6,11 @@ import { CircleProps } from './types'
export const CircleSvg = <RawDatum,>({
node,
style,
}: // onMouseEnter,
// onMouseMove,
// onMouseLeave,
// onClick,
CircleProps<RawDatum>) => {
// const handlers = {}
/*useNodeMouseHandlers<RawDatum>(node, {
onMouseEnter,
onMouseMove,
onMouseLeave,
onClick,
})*/

onMouseEnter,
onMouseMove,
onMouseLeave,
onClick,
}: CircleProps<RawDatum>) => {
return (
<animated.circle
key={node.id}
Expand All @@ -29,10 +21,10 @@ CircleProps<RawDatum>) => {
stroke={style.borderColor}
strokeWidth={style.borderWidth}
opacity={style.opacity}
// onMouseEnter={handlers.onMouseEnter}
// onMouseMove={handlers.onMouseMove}
// onMouseLeave={handlers.onMouseLeave}
// onClick={handlers.onClick}
onMouseEnter={event => onMouseEnter?.(node, event)}
onMouseMove={event => onMouseMove?.(node, event)}
onMouseLeave={event => onMouseLeave?.(node, event)}
onClick={event => onClick?.(node, event)}
/>
)
}
12 changes: 8 additions & 4 deletions packages/swarmplot/src/SwarmPlot.tsx
Expand Up @@ -51,10 +51,10 @@ const InnerSwarmPlot = <RawDatum,>({
axisBottom = defaultProps.axisBottom,
axisLeft = defaultProps.axisLeft,
isInteractive,
// onMouseEnter,
// onMouseMove,
// onMouseLeave,
// onClick,
onMouseEnter,
onMouseMove,
onMouseLeave,
onClick,
tooltip = defaultProps.tooltip,
annotations = defaultProps.annotations,
role = defaultProps.role,
Expand Down Expand Up @@ -136,6 +136,10 @@ const InnerSwarmPlot = <RawDatum,>({
isInteractive={isInteractive}
tooltip={tooltip}
component={circleComponent}
onMouseEnter={onMouseEnter}
onMouseMove={onMouseMove}
onMouseLeave={onMouseLeave}
onClick={onClick}
/>
)
}
Expand Down
@@ -1,9 +1,5 @@
import React from 'react'
import { mount } from 'enzyme'
// @ts-ignore
import { linearGradientDef, patternDotsDef } from '@nivo/core'
import { generateSwarmPlotData } from '@nivo/generators'
// @ts-ignore
import { SwarmPlot } from '../src'

const sampleData = [
Expand Down Expand Up @@ -111,7 +107,7 @@ describe('SwarmPlot', () => {
expect(datum.id).toEqual('A')
})

it.skip('should allow to completely disable interactivity', () => {
it('should allow to completely disable interactivity', () => {
const onClick = jest.fn()
const onMouseEnter = jest.fn()
const onMouseMove = jest.fn()
Expand Down Expand Up @@ -141,14 +137,6 @@ describe('SwarmPlot', () => {
expect(onMouseEnter).not.toHaveBeenCalled()
expect(onMouseMove).not.toHaveBeenCalled()
expect(onMouseLeave).not.toHaveBeenCalled()

wrapper.find('circle').forEach(node => {
const circle = node.find('circle')
expect(circle.prop('onClick')).toBeUndefined()
expect(circle.prop('onMouseEnter')).toBeUndefined()
expect(circle.prop('onMouseMove')).toBeUndefined()
expect(circle.prop('onMouseLeave')).toBeUndefined()
})
})
})
})

0 comments on commit b7aa6c7

Please sign in to comment.