2020-10-20 14:18:56 +02:00
|
|
|
describe('Chart.elements.PointElement', function() {
|
2018-10-20 11:38:48 +02:00
|
|
|
describe('auto', jasmine.fixture.specs('element.point'));
|
2015-08-29 05:09:58 +02:00
|
|
|
|
|
|
|
it ('Should correctly identify as in range', function() {
|
2019-12-27 23:13:24 +01:00
|
|
|
// Mock out the point as if we were made by the controller
|
2020-10-20 14:18:56 +02:00
|
|
|
var point = new Chart.elements.PointElement({
|
2019-12-27 23:13:24 +01:00
|
|
|
options: {
|
|
|
|
radius: 2,
|
|
|
|
hitRadius: 3,
|
|
|
|
},
|
2015-08-29 05:09:58 +02:00
|
|
|
x: 10,
|
|
|
|
y: 15
|
2019-12-27 23:13:24 +01:00
|
|
|
});
|
2015-08-29 05:09:58 +02:00
|
|
|
|
|
|
|
expect(point.inRange(10, 15)).toBe(true);
|
|
|
|
expect(point.inRange(10, 10)).toBe(false);
|
|
|
|
expect(point.inRange(10, 5)).toBe(false);
|
|
|
|
expect(point.inRange(5, 5)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it ('should get the correct tooltip position', function() {
|
2019-12-27 23:13:24 +01:00
|
|
|
// Mock out the point as if we were made by the controller
|
2020-10-20 14:18:56 +02:00
|
|
|
var point = new Chart.elements.PointElement({
|
2019-12-27 23:13:24 +01:00
|
|
|
options: {
|
|
|
|
radius: 2,
|
|
|
|
borderWidth: 6,
|
|
|
|
},
|
2015-08-29 05:09:58 +02:00
|
|
|
x: 10,
|
|
|
|
y: 15
|
2019-12-27 23:13:24 +01:00
|
|
|
});
|
2015-08-29 05:09:58 +02:00
|
|
|
|
|
|
|
expect(point.tooltipPosition()).toEqual({
|
|
|
|
x: 10,
|
2020-02-25 20:35:32 +01:00
|
|
|
y: 15
|
2015-08-29 05:09:58 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-10-03 22:05:21 +02:00
|
|
|
it('should get the correct center point', function() {
|
2019-12-27 23:13:24 +01:00
|
|
|
// Mock out the point as if we were made by the controller
|
2020-10-20 14:18:56 +02:00
|
|
|
var point = new Chart.elements.PointElement({
|
2019-12-27 23:13:24 +01:00
|
|
|
options: {
|
|
|
|
radius: 2,
|
|
|
|
},
|
2016-10-03 22:05:21 +02:00
|
|
|
x: 10,
|
|
|
|
y: 10
|
2019-12-27 23:13:24 +01:00
|
|
|
});
|
2016-10-03 22:05:21 +02:00
|
|
|
|
2016-10-16 23:34:59 +02:00
|
|
|
expect(point.getCenterPoint()).toEqual({x: 10, y: 10});
|
2016-10-03 22:05:21 +02:00
|
|
|
});
|
|
|
|
|
2015-08-29 05:09:58 +02:00
|
|
|
it ('should not draw if skipped', function() {
|
|
|
|
var mockContext = window.createMockContext();
|
|
|
|
|
2019-12-27 23:13:24 +01:00
|
|
|
// Mock out the point as if we were made by the controller
|
2020-10-20 14:18:56 +02:00
|
|
|
var point = new Chart.elements.PointElement({
|
2019-12-27 23:13:24 +01:00
|
|
|
options: {
|
|
|
|
radius: 2,
|
|
|
|
hitRadius: 3,
|
|
|
|
},
|
2015-08-29 05:09:58 +02:00
|
|
|
x: 10,
|
|
|
|
y: 15,
|
|
|
|
skip: true
|
2019-12-27 23:13:24 +01:00
|
|
|
});
|
2015-08-29 05:09:58 +02:00
|
|
|
|
2019-11-20 01:01:32 +01:00
|
|
|
point.draw(mockContext);
|
2015-08-29 05:09:58 +02:00
|
|
|
|
|
|
|
expect(mockContext.getCalls()).toEqual([]);
|
|
|
|
});
|
2016-10-16 23:34:59 +02:00
|
|
|
});
|