Skip to content

Commit

Permalink
test(point): update test for point.sensitivity (#3916)
Browse files Browse the repository at this point in the history
Co-authored-by: netil <[email protected]>
  • Loading branch information
netil and netil authored Nov 18, 2024
1 parent a09406c commit 0267766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ChartInternal/shape/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export default {
const mouse = getPointer(state.event, node);
const element = d3Select(node);
const prefix = this.isCirclePoint(node) ? "c" : "";
const pointSensitivity = this.getPointSensitivity(node);
const pointSensitivity = this.getPointSensitivity(element?.datum());

let cx = +element.attr(`${prefix}x`);
let cy = +element.attr(`${prefix}y`);
Expand Down
14 changes: 10 additions & 4 deletions test/shape/point-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ describe("SHAPE POINT", () => {
});

it("set options: poinst.sensitivity=function(){}", () => {
args.point.sensitivity = ({r}) => r
args.point.sensitivity = sinon.spy(({r}) => r);
});

it("should data.onclick callback called.", () => {
Expand All @@ -429,7 +429,10 @@ describe("SHAPE POINT", () => {
clientY: rect.top + 3
}, chart);

const spy = args.point.sensitivity.args[0][0];

expect(args.data.onclick.called).to.be.true;
expect(spy.r > 0).to.be.true;
});

it("set options", () => {
Expand All @@ -444,9 +447,9 @@ describe("SHAPE POINT", () => {
type: "line"
},
point: {
sensitivity: function(r) {
return 10;
},
sensitivity: sinon.spy(function(r) {
return 10;
}),
r: 10,
focus: {
expand: {
Expand All @@ -466,8 +469,11 @@ describe("SHAPE POINT", () => {
clientX: 300,
clientY: 40
}, chart);

const spy = args.point.sensitivity.args[0][0];

expect(args.data.onclick.called).to.be.true;
expect(spy.r > 0).to.be.true;
});
});

Expand Down

0 comments on commit 0267766

Please sign in to comment.