From e7b71aa9098803692d759f6acc3a60d1c71d3ab7 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sat, 24 Oct 2015 01:23:51 -0600 Subject: [PATCH] Line element and controller tests now coincide with the latest skipNull refactor --- test/controller.line.tests.js | 43 +++++++----------- test/element.line.tests.js | 82 +++++++++++++++++++++++++---------- 2 files changed, 73 insertions(+), 52 deletions(-) diff --git a/test/controller.line.tests.js b/test/controller.line.tests.js index 94e069d35..7e86c99bd 100644 --- a/test/controller.line.tests.js +++ b/test/controller.line.tests.js @@ -103,7 +103,7 @@ describe('Line controller tests', function() { expect(chart.data.datasets[0].metaData.length).toBe(3); }); - it ('should draw all elements', function() { + it('should draw all elements', function() { var chart = { data: { datasets: [{ @@ -141,7 +141,7 @@ describe('Line controller tests', function() { expect(chart.data.datasets[0].metaData[3].draw.calls.count()).toBe(1); }); - it ('should update elements', function() { + it('should update elements', function() { var data = { datasets: [{ data: [10, 15, 0, -4], @@ -210,7 +210,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'bevel', borderWidth: 1.2, fill: true, - skipNull: true, tension: 0.1, }, point: { @@ -251,8 +250,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'bevel', borderWidth: 1.2, fill: true, - drawNull: undefined, - skipNull: true, tension: 0.1, scaleTop: 0, @@ -268,7 +265,7 @@ describe('Line controller tests', function() { radius: 3, skip: false, tension: 0.1, - + // Point x: 71, y: 62, @@ -288,7 +285,7 @@ describe('Line controller tests', function() { radius: 3, skip: false, tension: 0.1, - + // Point x: 121, y: 15, @@ -308,7 +305,7 @@ describe('Line controller tests', function() { radius: 3, skip: false, tension: 0.1, - + // Point x: 172, y: 156, @@ -328,7 +325,7 @@ describe('Line controller tests', function() { radius: 3, skip: false, tension: 0.1, - + // Point x: 222, y: 194, @@ -350,8 +347,6 @@ describe('Line controller tests', function() { chart.data.datasets[0].borderDashOffset = 7; chart.data.datasets[0].borderJoinStyle = 'miter'; chart.data.datasets[0].fill = false; - chart.data.datasets[0].skipNull = false; - chart.data.datasets[0].drawNull = true; // point styles chart.data.datasets[0].radius = 22; @@ -371,8 +366,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'miter', borderWidth: 0.55, fill: false, - drawNull: true, - skipNull: false, tension: 0.2, scaleTop: 0, @@ -388,7 +381,7 @@ describe('Line controller tests', function() { radius: 22, skip: false, tension: 0.2, - + // Point x: 71, y: 62, @@ -408,7 +401,7 @@ describe('Line controller tests', function() { radius: 22, skip: false, tension: 0.2, - + // Point x: 121, y: 15, @@ -428,7 +421,7 @@ describe('Line controller tests', function() { radius: 22, skip: false, tension: 0.2, - + // Point x: 172, y: 156, @@ -448,7 +441,7 @@ describe('Line controller tests', function() { radius: 22, skip: false, tension: 0.2, - + // Point x: 222, y: 194, @@ -471,8 +464,6 @@ describe('Line controller tests', function() { borderDashOffset: 4.4, borderJoinStyle: 'round', fill: true, - skipNull: true, - drawNull: false, }; // point styles @@ -497,8 +488,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'round', borderWidth: 0.3, fill: true, - drawNull: true, - skipNull: false, tension: 0.25, scaleTop: 0, @@ -514,7 +503,7 @@ describe('Line controller tests', function() { radius: 2.2, skip: true, tension: 0.15, - + // Point x: 71, y: 62, @@ -527,7 +516,7 @@ describe('Line controller tests', function() { }); }); - it ('should handle number of data point changes in update', function() { + it('should handle number of data point changes in update', function() { var data = { datasets: [{ data: [10, 15, 0, -4], @@ -596,7 +585,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'bevel', borderWidth: 1.2, fill: true, - skipNull: true, tension: 0.1, }, point: { @@ -643,7 +631,7 @@ describe('Line controller tests', function() { expect(chart.data.datasets[0].metaData[4] instanceof Chart.elements.Point).toBe(true); }); - it ('should set point hover styles', function() { + it('should set point hover styles', function() { var data = { datasets: [{ data: [10, 15, 0, -4], @@ -777,7 +765,7 @@ describe('Line controller tests', function() { expect(point._model.radius).toBe(4.4); }); - it ('should remove hover styles', function() { + it('should remove hover styles', function() { var data = { datasets: [{ data: [10, 15, 0, -4], @@ -846,7 +834,6 @@ describe('Line controller tests', function() { borderJoinStyle: 'bevel', borderWidth: 1.2, fill: true, - skipNull: true, tension: 0.1, }, point: { @@ -915,4 +902,4 @@ describe('Line controller tests', function() { expect(point._model.borderWidth).toBe(5.5); expect(point._model.radius).toBe(4.4); }); -}); \ No newline at end of file +}); diff --git a/test/element.line.tests.js b/test/element.line.tests.js index 5e41d7ff2..e8b72b6a9 100644 --- a/test/element.line.tests.js +++ b/test/element.line.tests.js @@ -1,6 +1,6 @@ // Tests for the line element describe('Line element tests', function() { - it ('should be constructed', function() { + it('should be constructed', function() { var line = new Chart.elements.Line({ _datasetindex: 2, _points: [1, 2, 3, 4] @@ -11,7 +11,7 @@ describe('Line element tests', function() { expect(line._points).toEqual([1, 2, 3, 4]); }); - it ('should draw with default settings', function() { + it('should draw with default settings', function() { var mockContext = window.createMockContext(); // Create our points @@ -21,7 +21,7 @@ describe('Line element tests', function() { _index: 0, _view: { x: 0, - y: 10 + y: 10, } })); points.push(new Chart.elements.Point({ @@ -29,7 +29,7 @@ describe('Line element tests', function() { _index: 1, _view: { x: 5, - y: 0 + y: 0, } })); points.push(new Chart.elements.Point({ @@ -37,7 +37,7 @@ describe('Line element tests', function() { _index: 2, _view: { x: 15, - y: -10 + y: -10, } })); points.push(new Chart.elements.Point({ @@ -45,7 +45,7 @@ describe('Line element tests', function() { _index: 3, _view: { x: 19, - y: -5 + y: -5, } })); @@ -59,8 +59,9 @@ describe('Line element tests', function() { _view: { fill: false, // don't want to fill tension: 0.0, // no bezier curve for now + scaleZero: 0 } - }) + }); line.draw(); @@ -69,6 +70,9 @@ describe('Line element tests', function() { args: [], }, { name: 'moveTo', + args: [0, 0] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -84,7 +88,9 @@ describe('Line element tests', function() { args: ['butt'] }, { name: 'setLineDash', - args: [[]] + args: [ + [] + ] }, { name: 'setLineDashOffset', args: [0.0] @@ -102,6 +108,9 @@ describe('Line element tests', function() { args: [] }, { name: 'moveTo', + args: [0, 0] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -118,10 +127,10 @@ describe('Line element tests', function() { }, { name: 'restore', args: [] - }]) + }]); }); - it ('should draw with custom settings', function() { + it('should draw with custom settings', function() { var mockContext = window.createMockContext(); // Create our points @@ -167,7 +176,7 @@ describe('Line element tests', function() { _children: points, // Need to provide some settings _view: { - fill: true, + fill: true, scaleZero: 2, // for filling lines tension: 0.0, // no bezier curve for now @@ -179,7 +188,7 @@ describe('Line element tests', function() { borderWidth: 4, backgroundColor: 'rgb(0, 0, 0)' } - }) + }); line.draw(); @@ -188,6 +197,9 @@ describe('Line element tests', function() { args: [], }, { name: 'moveTo', + args: [0, 2] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -218,7 +230,9 @@ describe('Line element tests', function() { args: ['round'] }, { name: 'setLineDash', - args: [[2, 2]] + args: [ + [2, 2] + ] }, { name: 'setLineDashOffset', args: [1.5] @@ -236,6 +250,9 @@ describe('Line element tests', function() { args: [] }, { name: 'moveTo', + args: [0, 2] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -253,10 +270,10 @@ describe('Line element tests', function() { name: 'restore', args: [] }]; - expect(mockContext.getCalls()).toEqual(expected) + expect(mockContext.getCalls()).toEqual(expected); }); - it ('should be able to draw with a loop back to the beginning point', function() { + it('should be able to draw with a loop back to the beginning point', function() { var mockContext = window.createMockContext(); // Create our points @@ -305,8 +322,9 @@ describe('Line element tests', function() { _view: { fill: false, // don't want to fill tension: 0.0, // no bezier curve for now + scaleZero: 0, } - }) + }); line.draw(); @@ -315,6 +333,9 @@ describe('Line element tests', function() { args: [], }, { name: 'moveTo', + args: [0, 0] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -333,7 +354,9 @@ describe('Line element tests', function() { args: ['butt'] }, { name: 'setLineDash', - args: [[]] + args: [ + [] + ] }, { name: 'setLineDashOffset', args: [0.0] @@ -351,6 +374,9 @@ describe('Line element tests', function() { args: [] }, { name: 'moveTo', + args: [0, 0] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'lineTo', @@ -370,10 +396,10 @@ describe('Line element tests', function() { }, { name: 'restore', args: [] - }]) + }]); }); - it ('should draw with bezier curves if tension > 0', function() { + it('should draw with bezier curves if tension > 0', function() { var mockContext = window.createMockContext(); // Create our points @@ -435,7 +461,7 @@ describe('Line element tests', function() { _children: points, // Need to provide some settings _view: { - fill: true, + fill: true, scaleZero: 2, // for filling lines tension: 0.5, // have bezier curves @@ -447,7 +473,7 @@ describe('Line element tests', function() { borderWidth: 4, backgroundColor: 'rgb(0, 0, 0)' } - }) + }); line.draw(); @@ -456,6 +482,9 @@ describe('Line element tests', function() { args: [], }, { name: 'moveTo', + args: [0, 2] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'bezierCurveTo', @@ -486,7 +515,9 @@ describe('Line element tests', function() { args: ['round'] }, { name: 'setLineDash', - args: [[2, 2]] + args: [ + [2, 2] + ] }, { name: 'setLineDashOffset', args: [1.5] @@ -504,6 +535,9 @@ describe('Line element tests', function() { args: [] }, { name: 'moveTo', + args: [0, 2] + }, { + name: 'lineTo', args: [0, 10] }, { name: 'bezierCurveTo', @@ -521,6 +555,6 @@ describe('Line element tests', function() { name: 'restore', args: [] }]; - expect(mockContext.getCalls()).toEqual(expected) + expect(mockContext.getCalls()).toEqual(expected); }); -}); \ No newline at end of file +});