Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(point): update test for point.sensitivity #3916

Merged
merged 1 commit into from
Nov 18, 2024
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
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
Loading