From: andig Date: Sun, 27 Aug 2017 20:43:16 +0000 (+0200) Subject: Improve controller tests stability (#4698) X-Git-Tag: v2.7.0~1^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f950e2ab3a347b182e22774819c84d6e6dcfc19;p=thirdparty%2FChart.js.git Improve controller tests stability (#4698) --- diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index e01aecae6..315bdbd34 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1,5 +1,4 @@ -// Test the bar controller -describe('Bar controller tests', function() { +describe('Chart.controllers.bar', function() { it('should be constructed', function() { var chart = window.acquireChart({ type: 'bar', @@ -36,16 +35,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - id: 'firstXScaleID', - display: false + id: 'firstXScaleID' }], yAxes: [{ - id: 'firstYScaleID', - display: false + id: 'firstYScaleID' }] } } @@ -119,16 +114,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -156,16 +147,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -216,16 +203,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -253,16 +236,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -313,16 +292,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -350,16 +325,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -437,16 +408,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -477,16 +444,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -543,16 +506,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -583,16 +542,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -649,16 +604,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: true, - display: false + stacked: true }], yAxes: [{ - stacked: true, - display: false + stacked: true }] } } @@ -689,16 +640,12 @@ describe('Bar controller tests', function() { labels: [] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - stacked: false, - display: false + stacked: false }], yAxes: [{ - stacked: false, - display: false + stacked: false }] } } @@ -877,8 +824,8 @@ describe('Bar controller tests', function() { }], yAxes: [{ type: 'linear', - stacked: true, - display: false + display: false, + stacked: true }] } } @@ -936,8 +883,8 @@ describe('Bar controller tests', function() { }], yAxes: [{ type: 'linear', - stacked: true, display: false, + stacked: true, ticks: { min: 50, max: 100 @@ -995,8 +942,8 @@ describe('Bar controller tests', function() { scales: { xAxes: [{ type: 'category', - stacked: true, - display: false + display: false, + stacked: true }], yAxes: [{ type: 'linear', @@ -1058,8 +1005,8 @@ describe('Bar controller tests', function() { }], yAxes: [{ type: 'linear', - stacked: true, - display: false + display: false, + stacked: true }] } } @@ -1119,8 +1066,8 @@ describe('Bar controller tests', function() { }], yAxes: [{ type: 'linear', - stacked: true, - display: false + display: false, + stacked: true }] } } @@ -1177,9 +1124,9 @@ describe('Bar controller tests', function() { display: false }], yAxes: [{ - stacked: true, + type: 'linear', display: false, - type: 'linear' + stacked: true, }] } } @@ -1223,9 +1170,9 @@ describe('Bar controller tests', function() { display: false }], yAxes: [{ - stacked: true, + type: 'linear', display: false, - type: 'linear' + stacked: true }] } } @@ -1263,14 +1210,14 @@ describe('Bar controller tests', function() { scales: { xAxes: [{ type: 'category', - stacked: true, display: false, + stacked: true, barPercentage: 1, }], yAxes: [{ type: 'logarithmic', - stacked: true, - display: false + display: false, + stacked: true }] } } @@ -1347,8 +1294,6 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, elements: { rectangle: { backgroundColor: 'rgb(255, 0, 0)', @@ -1413,8 +1358,6 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, elements: { rectangle: { backgroundColor: 'rgb(255, 0, 0)', @@ -1506,11 +1449,8 @@ describe('Bar controller tests', function() { type: 'bar', data: this.data, options: { - legend: false, - title: false, scales: { xAxes: [{ - display: false, ticks: { min: 'March', max: 'May', @@ -1526,18 +1466,14 @@ describe('Bar controller tests', function() { type: 'bar', data: this.data, options: { - legend: false, - title: false, scales: { xAxes: [{ - display: false, ticks: { min: 'March', max: 'May', } }], yAxes: [{ - display: false, stacked: true }] } @@ -1590,8 +1526,6 @@ describe('Bar controller tests', function() { type: 'horizontalBar', data: this.data, options: { - legend: false, - title: false, scales: { yAxes: [{ ticks: { @@ -1609,15 +1543,11 @@ describe('Bar controller tests', function() { type: 'horizontalBar', data: this.data, options: { - legend: false, - title: false, scales: { xAxes: [{ - display: false, stacked: true }], yAxes: [{ - display: false, ticks: { min: 'March', max: 'May', @@ -1650,12 +1580,10 @@ describe('Bar controller tests', function() { xAxes: [{ id: 'x', type: 'category', - display: false, barThickness: barThickness }], yAxes: [{ type: 'linear', - display: false }] } } @@ -1725,7 +1653,6 @@ describe('Bar controller tests', function() { xAxes: [{ id: 'x', type: 'time', - display: false, time: { unit: 'year', parser: 'YYYY' @@ -1737,8 +1664,7 @@ describe('Bar controller tests', function() { distribution: distribution }], yAxes: [{ - type: 'linear', - display: false + type: 'linear' }] } } diff --git a/test/specs/controller.bubble.tests.js b/test/specs/controller.bubble.tests.js index 3fa3eb883..4799883dd 100644 --- a/test/specs/controller.bubble.tests.js +++ b/test/specs/controller.bubble.tests.js @@ -1,5 +1,4 @@ -// Test the bubble controller -describe('Bubble controller tests', function() { +describe('Chart.controllers.bubble', function() { it('should be constructed', function() { var chart = window.acquireChart({ type: 'bubble', @@ -120,12 +119,16 @@ describe('Bubble controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ - type: 'linear' + type: 'linear', + display: false }] } } @@ -134,10 +137,10 @@ describe('Bubble controller tests', function() { var meta = chart.getDatasetMeta(0); [ - {r: 5, x: 28, y: 32}, - {r: 1, x: 183, y: 484}, - {r: 2, x: 338, y: 461}, - {r: 1, x: 492, y: 32} + {r: 5, x: 0, y: 0}, + {r: 1, x: 171, y: 512}, + {r: 2, x: 341, y: 486}, + {r: 1, x: 512, y: 0} ].forEach(function(expected, i) { expect(meta.data[i]._model.radius).toBe(expected.r); expect(meta.data[i]._model.x).toBeCloseToPixel(expected.x); diff --git a/test/specs/controller.doughnut.tests.js b/test/specs/controller.doughnut.tests.js index f4c0c959e..85e382ac3 100644 --- a/test/specs/controller.doughnut.tests.js +++ b/test/specs/controller.doughnut.tests.js @@ -1,5 +1,4 @@ -// Test the bar controller -describe('Doughnut controller tests', function() { +describe('Chart.controllers.doughnut', function() { it('should be constructed', function() { var chart = window.acquireChart({ type: 'doughnut', @@ -69,6 +68,8 @@ describe('Doughnut controller tests', function() { labels: ['label0', 'label1', 'label2', 'label3'] }, options: { + legend: false, + title: false, animation: { animateRotate: true, animateScale: false @@ -99,9 +100,9 @@ describe('Doughnut controller tests', function() { {c: 0} ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(256); - expect(meta.data[i]._model.y).toBeCloseToPixel(272); - expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(239); - expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(179); + expect(meta.data[i]._model.y).toBeCloseToPixel(256); + expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(254); + expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(190); expect(meta.data[i]._model.circumference).toBeCloseTo(expected.c, 8); expect(meta.data[i]._model).toEqual(jasmine.objectContaining({ startAngle: Math.PI * -0.5, @@ -122,9 +123,9 @@ describe('Doughnut controller tests', function() { {c: 2.4434609527, s: 2.2689280275, e: 4.7123889803} ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(256); - expect(meta.data[i]._model.y).toBeCloseToPixel(272); - expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(239); - expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(179); + expect(meta.data[i]._model.y).toBeCloseToPixel(256); + expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(254); + expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(190); expect(meta.data[i]._model.circumference).toBeCloseTo(expected.c, 8); expect(meta.data[i]._model.startAngle).toBeCloseTo(expected.s, 8); expect(meta.data[i]._model.endAngle).toBeCloseTo(expected.e, 8); @@ -170,6 +171,8 @@ describe('Doughnut controller tests', function() { labels: ['label0', 'label1'] }, options: { + legend: false, + title: false, cutoutPercentage: 50, rotation: Math.PI, circumference: Math.PI * 0.5, @@ -192,10 +195,10 @@ describe('Doughnut controller tests', function() { {c: Math.PI / 8, s: Math.PI, e: Math.PI + Math.PI / 8}, {c: 3 * Math.PI / 8, s: Math.PI + Math.PI / 8, e: Math.PI + Math.PI / 2} ].forEach(function(expected, i) { - expect(meta.data[i]._model.x).toBeCloseToPixel(495); - expect(meta.data[i]._model.y).toBeCloseToPixel(511); - expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(478); - expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(359); + expect(meta.data[i]._model.x).toBeCloseToPixel(510); + expect(meta.data[i]._model.y).toBeCloseToPixel(510); + expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(509); + expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(381); expect(meta.data[i]._model.circumference).toBeCloseTo(expected.c, 8); expect(meta.data[i]._model.startAngle).toBeCloseTo(expected.s, 8); expect(meta.data[i]._model.endAngle).toBeCloseTo(expected.e, 8); diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index e1231dc69..31c0763a8 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -1,5 +1,4 @@ -// Test the line controller -describe('Line controller tests', function() { +describe('Chart.controllers.line', function() { it('should be constructed', function() { var chart = window.acquireChart({ type: 'line', @@ -175,6 +174,8 @@ describe('Line controller tests', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { point: { backgroundColor: 'red', @@ -183,10 +184,12 @@ describe('Line controller tests', function() { }, scales: { xAxes: [{ - id: 'firstXScaleID' + id: 'firstXScaleID', + display: false }], yAxes: [{ - id: 'firstYScaleID' + id: 'firstYScaleID', + display: false }] } }, @@ -203,8 +206,8 @@ describe('Line controller tests', function() { [ - {x: 33, y: 484}, - {x: 186, y: 32} + {x: 0, y: 512}, + {x: 171, y: 0} ].forEach(function(expected, i) { expect(meta.data[i]._datasetIndex).toBe(0); expect(meta.data[i]._index).toBe(i); @@ -234,11 +237,17 @@ describe('Line controller tests', function() { }] }, options: { + legend: false, + title: false, hover: { mode: 'single' }, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, ticks: { beginAtZero: true } @@ -250,7 +259,7 @@ describe('Line controller tests', function() { var meta = chart.getDatasetMeta(0); // 1 point var point = meta.data[0]; - expect(point._model.x).toBeCloseToPixel(27); + expect(point._model.x).toBeCloseToPixel(0); // 2 points chart.data.labels = ['One', 'Two']; @@ -259,8 +268,8 @@ describe('Line controller tests', function() { var points = meta.data; - expect(points[0]._model.x).toBeCloseToPixel(27); - expect(points[1]._model.x).toBeCloseToPixel(498); + expect(points[0]._model.x).toBeCloseToPixel(0); + expect(points[1]._model.x).toBeCloseToPixel(512); // 3 points chart.data.labels = ['One', 'Two', 'Three']; @@ -269,9 +278,9 @@ describe('Line controller tests', function() { points = meta.data; - expect(points[0]._model.x).toBeCloseToPixel(27); - expect(points[1]._model.x).toBeCloseToPixel(260); - expect(points[2]._model.x).toBeCloseToPixel(493); + expect(points[0]._model.x).toBeCloseToPixel(0); + expect(points[1]._model.x).toBeCloseToPixel(256); + expect(points[2]._model.x).toBeCloseToPixel(512); // 4 points chart.data.labels = ['One', 'Two', 'Three', 'Four']; @@ -280,10 +289,10 @@ describe('Line controller tests', function() { points = meta.data; - expect(points[0]._model.x).toBeCloseToPixel(27); - expect(points[1]._model.x).toBeCloseToPixel(184); + expect(points[0]._model.x).toBeCloseToPixel(0); + expect(points[1]._model.x).toBeCloseToPixel(171); expect(points[2]._model.x).toBeCloseToPixel(340); - expect(points[3]._model.x).toBeCloseToPixel(497); + expect(points[3]._model.x).toBeCloseToPixel(512); }); it('should update elements when the y scale is stacked', function() { @@ -300,8 +309,14 @@ describe('Line controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } @@ -311,10 +326,10 @@ describe('Line controller tests', function() { var meta0 = chart.getDatasetMeta(0); [ - {x: 28, y: 161}, - {x: 183, y: 419}, - {x: 338, y: 161}, - {x: 492, y: 419} + {x: 0, y: 146}, + {x: 171, y: 439}, + {x: 341, y: 146}, + {x: 512, y: 439} ].forEach(function(values, i) { expect(meta0.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta0.data[i]._model.y).toBeCloseToPixel(values.y); @@ -323,10 +338,10 @@ describe('Line controller tests', function() { var meta1 = chart.getDatasetMeta(1); [ - {x: 28, y: 32}, - {x: 183, y: 97}, - {x: 338, y: 161}, - {x: 492, y: 471} + {x: 0, y: 0}, + {x: 171, y: 73}, + {x: 341, y: 146}, + {x: 512, y: 497} ].forEach(function(values, i) { expect(meta1.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta1.data[i]._model.y).toBeCloseToPixel(values.y); @@ -352,12 +367,19 @@ describe('Line controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }, { + id: 'secondAxis', type: 'linear', - id: 'secondAxis' + display: false }] } } @@ -366,10 +388,10 @@ describe('Line controller tests', function() { var meta0 = chart.getDatasetMeta(0); [ - {x: 56, y: 161}, - {x: 202, y: 419}, - {x: 347, y: 161}, - {x: 492, y: 419} + {x: 0, y: 146}, + {x: 171, y: 439}, + {x: 341, y: 146}, + {x: 512, y: 439} ].forEach(function(values, i) { expect(meta0.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta0.data[i]._model.y).toBeCloseToPixel(values.y); @@ -378,10 +400,10 @@ describe('Line controller tests', function() { var meta1 = chart.getDatasetMeta(1); [ - {x: 56, y: 32}, - {x: 202, y: 97}, - {x: 347, y: 161}, - {x: 492, y: 471} + {x: 0, y: 0}, + {x: 171, y: 73}, + {x: 341, y: 146}, + {x: 512, y: 497} ].forEach(function(values, i) { expect(meta1.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta1.data[i]._model.y).toBeCloseToPixel(values.y); @@ -427,8 +449,14 @@ describe('Line controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } @@ -438,10 +466,10 @@ describe('Line controller tests', function() { var meta0 = chart.getDatasetMeta(0); [ - {x: 28, y: 161}, - {x: 183, y: 419}, - {x: 338, y: 161}, - {x: 492, y: 419} + {x: 0, y: 146}, + {x: 171, y: 439}, + {x: 341, y: 146}, + {x: 512, y: 439} ].forEach(function(values, i) { expect(meta0.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta0.data[i]._model.y).toBeCloseToPixel(values.y); @@ -450,10 +478,10 @@ describe('Line controller tests', function() { var meta1 = chart.getDatasetMeta(1); [ - {x: 28, y: 32}, - {x: 183, y: 97}, - {x: 338, y: 161}, - {x: 492, y: 471} + {x: 0, y: 0}, + {x: 171, y: 73}, + {x: 341, y: 146}, + {x: 512, y: 497} ].forEach(function(values, i) { expect(meta1.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta1.data[i]._model.y).toBeCloseToPixel(values.y); @@ -475,8 +503,14 @@ describe('Line controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } @@ -486,10 +520,10 @@ describe('Line controller tests', function() { var meta0 = chart.getDatasetMeta(0); [ - {x: 28, y: 161}, - {x: 183, y: 419}, - {x: 338, y: 161}, - {x: 492, y: 419} + {x: 0, y: 146}, + {x: 171, y: 439}, + {x: 341, y: 146}, + {x: 512, y: 439} ].forEach(function(values, i) { expect(meta0.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta0.data[i]._model.y).toBeCloseToPixel(values.y); @@ -498,10 +532,10 @@ describe('Line controller tests', function() { var meta1 = chart.getDatasetMeta(1); [ - {x: 28, y: 32}, - {x: 183, y: 97}, - {x: 338, y: 161}, - {x: 492, y: 471} + {x: 0, y: 0}, + {x: 171, y: 73}, + {x: 341, y: 146}, + {x: 512, y: 497} ].forEach(function(values, i) { expect(meta1.data[i]._model.x).toBeCloseToPixel(values.x); expect(meta1.data[i]._model.y).toBeCloseToPixel(values.y); diff --git a/test/specs/controller.polarArea.tests.js b/test/specs/controller.polarArea.tests.js index 636473cab..050bd68b8 100644 --- a/test/specs/controller.polarArea.tests.js +++ b/test/specs/controller.polarArea.tests.js @@ -1,5 +1,4 @@ -// Test the polar area controller -describe('Polar area controller tests', function() { +describe('Chart.controllers.polarArea', function() { it('should be constructed', function() { var chart = window.acquireChart({ type: 'polarArea', @@ -82,6 +81,8 @@ describe('Polar area controller tests', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { arc: { backgroundColor: 'rgb(255, 0, 0)', @@ -96,13 +97,13 @@ describe('Polar area controller tests', function() { expect(meta.data.length).toBe(4); [ - {o: 168, s: -0.5 * Math.PI, e: 0}, - {o: 228, s: 0, e: 0.5 * Math.PI}, - {o: 48, s: 0.5 * Math.PI, e: Math.PI}, + {o: 179, s: -0.5 * Math.PI, e: 0}, + {o: 243, s: 0, e: 0.5 * Math.PI}, + {o: 51, s: 0.5 * Math.PI, e: Math.PI}, {o: 0, s: Math.PI, e: 1.5 * Math.PI} ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(256); - expect(meta.data[i]._model.y).toBeCloseToPixel(272); + expect(meta.data[i]._model.y).toBeCloseToPixel(256); expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(0); expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(expected.o); expect(meta.data[i]._model.startAngle).toBe(expected.s); @@ -138,9 +139,9 @@ describe('Polar area controller tests', function() { chart.update(); expect(meta.data[0]._model.x).toBeCloseToPixel(256); - expect(meta.data[0]._model.y).toBeCloseToPixel(272); + expect(meta.data[0]._model.y).toBeCloseToPixel(256); expect(meta.data[0]._model.innerRadius).toBeCloseToPixel(0); - expect(meta.data[0]._model.outerRadius).toBeCloseToPixel(168); + expect(meta.data[0]._model.outerRadius).toBeCloseToPixel(179); expect(meta.data[0]._model).toEqual(jasmine.objectContaining({ startAngle: -0.5 * Math.PI, endAngle: 0, @@ -163,6 +164,8 @@ describe('Polar area controller tests', function() { }, options: { showLines: true, + legend: false, + title: false, startAngle: 0, // default is -0.5 * Math.PI elements: { arc: { @@ -178,13 +181,13 @@ describe('Polar area controller tests', function() { expect(meta.data.length).toBe(4); [ - {o: 168, s: 0, e: 0.5 * Math.PI}, - {o: 228, s: 0.5 * Math.PI, e: Math.PI}, - {o: 48, s: Math.PI, e: 1.5 * Math.PI}, + {o: 179, s: 0, e: 0.5 * Math.PI}, + {o: 243, s: 0.5 * Math.PI, e: Math.PI}, + {o: 51, s: Math.PI, e: 1.5 * Math.PI}, {o: 0, s: 1.5 * Math.PI, e: 2.0 * Math.PI} ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(256); - expect(meta.data[i]._model.y).toBeCloseToPixel(272); + expect(meta.data[i]._model.y).toBeCloseToPixel(256); expect(meta.data[i]._model.innerRadius).toBeCloseToPixel(0); expect(meta.data[i]._model.outerRadius).toBeCloseToPixel(expected.o); expect(meta.data[i]._model.startAngle).toBe(expected.s); diff --git a/test/specs/controller.radar.tests.js b/test/specs/controller.radar.tests.js index 38959a509..df1001420 100644 --- a/test/specs/controller.radar.tests.js +++ b/test/specs/controller.radar.tests.js @@ -1,5 +1,4 @@ -// Test the polar area controller -describe('Radar controller tests', function() { +describe('Chart.controllers.radar', function() { it('Should be constructed', function() { var chart = window.acquireChart({ type: 'radar', @@ -80,6 +79,8 @@ describe('Radar controller tests', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { line: { backgroundColor: 'rgb(255, 0, 0)', @@ -124,10 +125,10 @@ describe('Radar controller tests', function() { })); [ - {x: 256, y: 272, cppx: 256, cppy: 272, cpnx: 256, cpny: 272}, - {x: 256, y: 272, cppx: 256, cppy: 272, cpnx: 256, cpny: 272}, - {x: 256, y: 272, cppx: 256, cppy: 272, cpnx: 256, cpny: 272}, - {x: 256, y: 272, cppx: 256, cppy: 272, cpnx: 256, cpny: 272}, + {x: 256, y: 256, cppx: 256, cppy: 256, cpnx: 256, cpny: 256}, + {x: 256, y: 256, cppx: 256, cppy: 256, cpnx: 256, cpny: 256}, + {x: 256, y: 256, cppx: 256, cppy: 256, cpnx: 256, cpny: 256}, + {x: 256, y: 256, cppx: 256, cppy: 256, cpnx: 256, cpny: 256}, ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(expected.x); expect(meta.data[i]._model.y).toBeCloseToPixel(expected.y); @@ -151,10 +152,10 @@ describe('Radar controller tests', function() { meta.controller.update(); [ - {x: 256, y: 133, cppx: 246, cppy: 133, cpnx: 272, cpny: 133}, - {x: 464, y: 272, cppx: 464, cppy: 264, cpnx: 464, cpny: 278}, - {x: 256, y: 272, cppx: 276.9, cppy: 272, cpnx: 250.4, cpny: 272}, - {x: 200, y: 272, cppx: 200, cppy: 275, cpnx: 200, cpny: 261}, + {x: 256, y: 117, cppx: 246, cppy: 117, cpnx: 272, cpny: 117}, + {x: 464, y: 256, cppx: 464, cppy: 248, cpnx: 464, cpny: 262}, + {x: 256, y: 256, cppx: 276.9, cppy: 256, cpnx: 250.4, cpny: 256}, + {x: 200, y: 256, cppx: 200, cppy: 259, cpnx: 200, cpny: 245}, ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(expected.x); expect(meta.data[i]._model.y).toBeCloseToPixel(expected.y); @@ -208,10 +209,10 @@ describe('Radar controller tests', function() { // Since tension is now 0, we don't care about the control points [ - {x: 256, y: 133}, - {x: 464, y: 272}, - {x: 256, y: 272}, - {x: 200, y: 272}, + {x: 256, y: 117}, + {x: 464, y: 256}, + {x: 256, y: 256}, + {x: 200, y: 256}, ].forEach(function(expected, i) { expect(meta.data[i]._model.x).toBeCloseToPixel(expected.x); expect(meta.data[i]._model.y).toBeCloseToPixel(expected.y); @@ -267,11 +268,11 @@ describe('Radar controller tests', function() { })); expect(meta.data[0]._model.x).toBeCloseToPixel(256); - expect(meta.data[0]._model.y).toBeCloseToPixel(133); + expect(meta.data[0]._model.y).toBeCloseToPixel(117); expect(meta.data[0]._model.controlPointPreviousX).toBeCloseToPixel(241); - expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(133); + expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(117); expect(meta.data[0]._model.controlPointNextX).toBeCloseToPixel(281); - expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(133); + expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(117); expect(meta.data[0]._model).toEqual(jasmine.objectContaining({ radius: 2.2, backgroundColor: 'rgb(0, 1, 3)',