Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

pass more props to flyout #244

Merged
merged 1 commit into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/victory-tooltip/victory-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ export default class VictoryTooltip extends React.Component {
getFlyoutProps(props, calculatedValues) {
const { flyoutDimensions, flyoutStyle } = calculatedValues;
const {
x, y, dx, dy, orientation, pointerLength, pointerWidth, cornerRadius,
events, flyoutComponent, index
x, y, dx, dy, datum, index, orientation, pointerLength, pointerWidth,
cornerRadius, events, flyoutComponent
} = props;
return defaults(
{},
flyoutComponent.props,
{
x, y, dx, dy, orientation, pointerLength, pointerWidth, cornerRadius, events,
x, y, dx, dy, datum, index, orientation, pointerLength, pointerWidth, cornerRadius, events,
key: `flyout-${index}`,
width: flyoutDimensions.width,
height: flyoutDimensions.height,
Expand Down
15 changes: 13 additions & 2 deletions test/client/spec/victory-tooltip/victory-tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import VictoryLabel from "src/victory-label/victory-label";
import VictoryTooltip from "src/victory-tooltip/victory-tooltip";
import Flyout from "src/victory-primitives/flyout";

describe("components/victory-label", () => {
const baseProps = { x: 0, y: 0, active: true, text: "such text, wow" };
describe("components/victory-tooltip", () => {
const baseProps = { x: 0, y: 0, datum: { some: "object" }, index: 3,
active: true, text: "such text, wow" };

it("renders nothing when not active", () => {
const wrapper = mount(
<VictoryTooltip {...baseProps} active={false}/>
Expand All @@ -36,6 +38,15 @@ describe("components/victory-label", () => {
expect(flyout.length).to.equal(1);
});

it("passes datum and index to flyout component", () => {
const wrapper = mount(
<VictoryTooltip {...baseProps}/>
);
const flyout = wrapper.find(Flyout);
expect(flyout.prop("datum")).to.eql({ some: "object" });
expect(flyout.prop("index")).to.eql(3);
});

describe("event handling", () => {
it("attaches an to the flyout object", () => {
const clickHandler = sinon.spy();
Expand Down