1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
describe('Chart.elements.PointElement', function() {
describe('auto', jasmine.fixture.specs('element.point'));
it ('Should correctly identify as in range', function() {
// Mock out the point as if we were made by the controller
var point = new Chart.elements.PointElement({
options: {
radius: 2,
hitRadius: 3,
},
x: 10,
y: 15
});
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() {
// Mock out the point as if we were made by the controller
var point = new Chart.elements.PointElement({
options: {
radius: 2,
borderWidth: 6,
},
x: 10,
y: 15
});
expect(point.tooltipPosition()).toEqual({
x: 10,
y: 15
});
});
it('should get the correct center point', function() {
// Mock out the point as if we were made by the controller
var point = new Chart.elements.PointElement({
options: {
radius: 2,
},
x: 10,
y: 10
});
expect(point.getCenterPoint()).toEqual({x: 10, y: 10});
});
it ('should not draw if skipped', function() {
var mockContext = window.createMockContext();
// Mock out the point as if we were made by the controller
var point = new Chart.elements.PointElement({
options: {
radius: 2,
hitRadius: 3,
},
x: 10,
y: 15,
skip: true
});
point.draw(mockContext);
expect(mockContext.getCalls()).toEqual([]);
});
});
|