From db0d1985fa11f4e64e46d8f864b8a3af8807a44f Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 26 Aug 2017 11:01:41 +0200 Subject: [PATCH 1/4] Improve test stability --- test/specs/controller.bar.tests.js | 219 ++++++++------------------ test/specs/controller.bubble.tests.js | 28 +++- test/specs/controller.line.tests.js | 106 ++++++++----- test/specs/controller.radar.tests.js | 50 ++++-- 4 files changed, 185 insertions(+), 218 deletions(-) diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index e01aecae6e4..1c51a3561f8 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1,5 +1,25 @@ // Test the bar controller describe('Bar controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + legend: false, + title: false + }, + scale: { + display: false + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('should be constructed', function() { var chart = window.acquireChart({ type: 'bar', @@ -36,16 +56,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 +135,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 +168,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 +224,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 +257,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 +313,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 +346,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 +429,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 +465,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 +527,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 +563,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 +625,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 +661,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 }] } } @@ -747,8 +715,6 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, elements: { rectangle: { backgroundColor: 'red', @@ -760,13 +726,11 @@ describe('Bar controller tests', function() { scales: { xAxes: [{ id: 'firstXScaleID', - type: 'category', - display: false + type: 'category' }], yAxes: [{ id: 'firstYScaleID', - type: 'linear', - display: false + type: 'linear' }] } } @@ -827,16 +791,12 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ - type: 'linear', - display: false + type: 'linear' }] } } @@ -868,17 +828,13 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ type: 'linear', - stacked: true, - display: false + stacked: true }] } } @@ -927,17 +883,13 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ type: 'linear', stacked: true, - display: false, ticks: { min: 50, max: 100 @@ -990,17 +942,13 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ type: 'category', - stacked: true, - display: false + stacked: true }], yAxes: [{ - type: 'linear', - display: false + type: 'linear' }] } } @@ -1049,17 +997,13 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ type: 'linear', - stacked: true, - display: false + stacked: true }] } } @@ -1110,17 +1054,13 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ type: 'linear', - stacked: true, - display: false + stacked: true }] } } @@ -1169,16 +1109,12 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ stacked: true, - display: false, type: 'linear' }] } @@ -1215,16 +1151,12 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ - type: 'category', - display: false + type: 'category' }], yAxes: [{ stacked: true, - display: false, type: 'linear' }] } @@ -1258,19 +1190,15 @@ describe('Bar controller tests', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, scales: { xAxes: [{ type: 'category', stacked: true, - display: false, barPercentage: 1, }], yAxes: [{ type: 'logarithmic', - stacked: true, - display: false + stacked: true }] } } @@ -1347,8 +1275,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 +1339,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 +1430,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 +1447,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 +1507,6 @@ describe('Bar controller tests', function() { type: 'horizontalBar', data: this.data, options: { - legend: false, - title: false, scales: { yAxes: [{ ticks: { @@ -1609,15 +1524,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 +1561,10 @@ describe('Bar controller tests', function() { xAxes: [{ id: 'x', type: 'category', - display: false, barThickness: barThickness }], yAxes: [{ type: 'linear', - display: false }] } } @@ -1725,7 +1634,6 @@ describe('Bar controller tests', function() { xAxes: [{ id: 'x', type: 'time', - display: false, time: { unit: 'year', parser: 'YYYY' @@ -1737,8 +1645,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 3fa3eb883cd..d1b4fa05d0e 100644 --- a/test/specs/controller.bubble.tests.js +++ b/test/specs/controller.bubble.tests.js @@ -1,5 +1,25 @@ // Test the bubble controller describe('Bubble controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + legend: false, + title: false + }, + scale: { + display: false + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('should be constructed', function() { var chart = window.acquireChart({ type: 'bubble', @@ -134,10 +154,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.line.tests.js b/test/specs/controller.line.tests.js index e1231dc692c..008083ca8e5 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -1,5 +1,25 @@ // Test the line controller describe('Line controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + legend: false, + title: false + }, + scale: { + display: false + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('should be constructed', function() { var chart = window.acquireChart({ type: 'line', @@ -203,8 +223,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); @@ -250,7 +270,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 +279,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 +289,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 +300,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() { @@ -311,10 +331,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 +343,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); @@ -366,10 +386,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 +398,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); @@ -438,10 +458,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 +470,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); @@ -486,10 +506,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 +518,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.radar.tests.js b/test/specs/controller.radar.tests.js index 38959a50978..3ac8e4e68a9 100644 --- a/test/specs/controller.radar.tests.js +++ b/test/specs/controller.radar.tests.js @@ -1,5 +1,25 @@ // Test the polar area controller describe('Radar controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + legend: false, + title: false + }, + scale: { + display: false + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('Should be constructed', function() { var chart = window.acquireChart({ type: 'radar', @@ -124,10 +144,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 +171,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: 116, cppx: 246, cppy: 116, cpnx: 272, cpny: 116}, + {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 +228,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: 116}, + {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 +287,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(116); expect(meta.data[0]._model.controlPointPreviousX).toBeCloseToPixel(241); - expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(133); + expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(116); expect(meta.data[0]._model.controlPointNextX).toBeCloseToPixel(281); - expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(133); + expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(116); expect(meta.data[0]._model).toEqual(jasmine.objectContaining({ radius: 2.2, backgroundColor: 'rgb(0, 1, 3)', From cb8223cb25beede1dffb95f26ec661af2152ba18 Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 26 Aug 2017 12:08:44 +0200 Subject: [PATCH 2/4] Improve test stability --- test/specs/controller.doughnut.tests.js | 39 ++++++++++++++++------ test/specs/controller.polarArea.tests.js | 42 ++++++++++++++++++------ 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/test/specs/controller.doughnut.tests.js b/test/specs/controller.doughnut.tests.js index f4c0c959e30..cc2466b25f3 100644 --- a/test/specs/controller.doughnut.tests.js +++ b/test/specs/controller.doughnut.tests.js @@ -1,5 +1,24 @@ // Test the bar controller describe('Doughnut controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + plugins: { + legend: false, + title: false + } + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('should be constructed', function() { var chart = window.acquireChart({ type: 'doughnut', @@ -99,9 +118,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 +141,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); @@ -192,10 +211,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.polarArea.tests.js b/test/specs/controller.polarArea.tests.js index 636473cabf7..a059d64d4e7 100644 --- a/test/specs/controller.polarArea.tests.js +++ b/test/specs/controller.polarArea.tests.js @@ -1,5 +1,27 @@ // Test the polar area controller describe('Polar area controller tests', function() { + + // set global test options + beforeAll(function() { + this._options = Chart.helpers.clone(Chart.defaults); + Chart.helpers.merge(Chart.defaults, { + global: { + scale: { + display: false + }, + plugins: { + legend: false, + title: false + } + } + }); + }); + + // restore default chart config + afterAll(function() { + Chart.helpers.merge(Chart.defaults, this._options); + }); + it('should be constructed', function() { var chart = window.acquireChart({ type: 'polarArea', @@ -96,13 +118,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 +160,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, @@ -178,13 +200,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); From 9f1e3749fa2f8f42d37f53338852328cf18b15f3 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sun, 27 Aug 2017 11:54:41 +0200 Subject: [PATCH 3/4] Fix unit tests defaults --- test/jasmine.index.js | 1 + test/jasmine.utils.js | 36 ++++++++++++++++++++++++ test/specs/controller.bar.tests.js | 18 ++++++------ test/specs/controller.bubble.tests.js | 18 ++++++------ test/specs/controller.doughnut.tests.js | 12 ++++---- test/specs/controller.line.tests.js | 18 ++++++------ test/specs/controller.polarArea.tests.js | 18 ++++++------ test/specs/controller.radar.tests.js | 18 ++++++------ 8 files changed, 86 insertions(+), 53 deletions(-) diff --git a/test/jasmine.index.js b/test/jasmine.index.js index c1706130f2d..cd643852b47 100644 --- a/test/jasmine.index.js +++ b/test/jasmine.index.js @@ -42,6 +42,7 @@ var utils = require('./jasmine.utils'); 'position: absolute' + '}'); + jasmine.overrideDefaults = utils.overrideDefaults; jasmine.specsFromFixtures = utils.specsFromFixtures; jasmine.triggerMouseEvent = utils.triggerMouseEvent; diff --git a/test/jasmine.utils.js b/test/jasmine.utils.js index c94249406a2..f7d264bb003 100644 --- a/test/jasmine.utils.js +++ b/test/jasmine.utils.js @@ -172,11 +172,47 @@ function triggerMouseEvent(chart, type, el) { node.dispatchEvent(event); } +/** + * Merges the given values into `Chart.defaults` and returns previous overwritten values. + */ +function overrideDefaults(values) { + var helpers = Chart.helpers; + var diff = {}; + + function merger(key, target, source, options) { + var changes = options.changes || {}; + var tval = target[key]; + var sval = source[key]; + + if (helpers.isObject(tval) && helpers.isObject(sval)) { + helpers.merge(tval, sval, { + changes: changes[key] = {}, + merger: merger + }); + } else { + changes[key] = helpers.clone(tval); + if (sval !== undefined) { + target[key] = helpers.clone(sval); + } else { + delete target[key]; + } + } + } + + helpers.merge(Chart.defaults, values, { + changes: diff, + merger: merger + }); + + return diff; +} + module.exports = { injectCSS: injectCSS, createCanvas: createCanvas, acquireChart: acquireChart, releaseChart: releaseChart, + overrideDefaults: overrideDefaults, specsFromFixtures: specsFromFixtures, triggerMouseEvent: triggerMouseEvent, waitForResize: waitForResize diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 1c51a3561f8..a040160e6e0 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1,13 +1,13 @@ -// Test the bar controller -describe('Bar controller tests', function() { +describe('Chart.controllers.bar', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { - legend: false, - title: false + plugins: { + legend: false, + title: false + } }, scale: { display: false @@ -15,9 +15,9 @@ describe('Bar controller tests', function() { }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('should be constructed', function() { diff --git a/test/specs/controller.bubble.tests.js b/test/specs/controller.bubble.tests.js index d1b4fa05d0e..6589afa12dd 100644 --- a/test/specs/controller.bubble.tests.js +++ b/test/specs/controller.bubble.tests.js @@ -1,13 +1,13 @@ -// Test the bubble controller -describe('Bubble controller tests', function() { +describe('Chart.controllers.bubble', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { - legend: false, - title: false + plugins: { + legend: false, + title: false + } }, scale: { display: false @@ -15,9 +15,9 @@ describe('Bubble controller tests', function() { }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('should be constructed', function() { diff --git a/test/specs/controller.doughnut.tests.js b/test/specs/controller.doughnut.tests.js index cc2466b25f3..12bc14a8fec 100644 --- a/test/specs/controller.doughnut.tests.js +++ b/test/specs/controller.doughnut.tests.js @@ -1,10 +1,8 @@ -// Test the bar controller -describe('Doughnut controller tests', function() { +describe('Chart.controllers.doughnut', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { plugins: { legend: false, @@ -14,9 +12,9 @@ describe('Doughnut controller tests', function() { }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('should be constructed', function() { diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index 008083ca8e5..94b4fd88fef 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -1,13 +1,13 @@ -// Test the line controller -describe('Line controller tests', function() { +describe('Chart.controllers.line', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { - legend: false, - title: false + plugins: { + legend: false, + title: false + } }, scale: { display: false @@ -15,9 +15,9 @@ describe('Line controller tests', function() { }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('should be constructed', function() { diff --git a/test/specs/controller.polarArea.tests.js b/test/specs/controller.polarArea.tests.js index a059d64d4e7..2d8c48f3233 100644 --- a/test/specs/controller.polarArea.tests.js +++ b/test/specs/controller.polarArea.tests.js @@ -1,25 +1,23 @@ -// Test the polar area controller -describe('Polar area controller tests', function() { +describe('Chart.controllers.polarArea', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { - scale: { - display: false - }, plugins: { legend: false, title: false } + }, + scale: { + display: false } }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('should be constructed', function() { diff --git a/test/specs/controller.radar.tests.js b/test/specs/controller.radar.tests.js index 3ac8e4e68a9..2e4b28d1e24 100644 --- a/test/specs/controller.radar.tests.js +++ b/test/specs/controller.radar.tests.js @@ -1,13 +1,13 @@ -// Test the polar area controller -describe('Radar controller tests', function() { +describe('Chart.controllers.radar', function() { - // set global test options beforeAll(function() { - this._options = Chart.helpers.clone(Chart.defaults); - Chart.helpers.merge(Chart.defaults, { + // set global test options + this._defaults = jasmine.overrideDefaults({ global: { - legend: false, - title: false + plugins: { + legend: false, + title: false + } }, scale: { display: false @@ -15,9 +15,9 @@ describe('Radar controller tests', function() { }); }); - // restore default chart config afterAll(function() { - Chart.helpers.merge(Chart.defaults, this._options); + // restore default chart config + jasmine.overrideDefaults(this._defaults); }); it('Should be constructed', function() { From b7af0f14ff4d71462ca8022a57bc368f8c92f897 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sun, 27 Aug 2017 11:54:41 +0200 Subject: [PATCH 4/4] Revert global defaults, locally setup charts instead --- test/jasmine.index.js | 1 - test/jasmine.utils.js | 36 ---------- test/specs/controller.bar.tests.js | 89 ++++++++++++++---------- test/specs/controller.bubble.tests.js | 29 ++------ test/specs/controller.doughnut.tests.js | 22 ++---- test/specs/controller.line.tests.js | 62 ++++++++++------- test/specs/controller.polarArea.tests.js | 25 ++----- test/specs/controller.radar.tests.js | 33 ++------- 8 files changed, 113 insertions(+), 184 deletions(-) diff --git a/test/jasmine.index.js b/test/jasmine.index.js index cd643852b47..c1706130f2d 100644 --- a/test/jasmine.index.js +++ b/test/jasmine.index.js @@ -42,7 +42,6 @@ var utils = require('./jasmine.utils'); 'position: absolute' + '}'); - jasmine.overrideDefaults = utils.overrideDefaults; jasmine.specsFromFixtures = utils.specsFromFixtures; jasmine.triggerMouseEvent = utils.triggerMouseEvent; diff --git a/test/jasmine.utils.js b/test/jasmine.utils.js index f7d264bb003..c94249406a2 100644 --- a/test/jasmine.utils.js +++ b/test/jasmine.utils.js @@ -172,47 +172,11 @@ function triggerMouseEvent(chart, type, el) { node.dispatchEvent(event); } -/** - * Merges the given values into `Chart.defaults` and returns previous overwritten values. - */ -function overrideDefaults(values) { - var helpers = Chart.helpers; - var diff = {}; - - function merger(key, target, source, options) { - var changes = options.changes || {}; - var tval = target[key]; - var sval = source[key]; - - if (helpers.isObject(tval) && helpers.isObject(sval)) { - helpers.merge(tval, sval, { - changes: changes[key] = {}, - merger: merger - }); - } else { - changes[key] = helpers.clone(tval); - if (sval !== undefined) { - target[key] = helpers.clone(sval); - } else { - delete target[key]; - } - } - } - - helpers.merge(Chart.defaults, values, { - changes: diff, - merger: merger - }); - - return diff; -} - module.exports = { injectCSS: injectCSS, createCanvas: createCanvas, acquireChart: acquireChart, releaseChart: releaseChart, - overrideDefaults: overrideDefaults, specsFromFixtures: specsFromFixtures, triggerMouseEvent: triggerMouseEvent, waitForResize: waitForResize diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index a040160e6e0..315bdbd346b 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1,25 +1,4 @@ describe('Chart.controllers.bar', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - }, - scale: { - display: false - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'bar', @@ -715,6 +694,8 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, elements: { rectangle: { backgroundColor: 'red', @@ -726,11 +707,13 @@ describe('Chart.controllers.bar', function() { scales: { xAxes: [{ id: 'firstXScaleID', - type: 'category' + type: 'category', + display: false }], yAxes: [{ id: 'firstYScaleID', - type: 'linear' + type: 'linear', + display: false }] } } @@ -791,12 +774,16 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ - type: 'linear' + type: 'linear', + display: false }] } } @@ -828,12 +815,16 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ type: 'linear', + display: false, stacked: true }] } @@ -883,12 +874,16 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ type: 'linear', + display: false, stacked: true, ticks: { min: 50, @@ -942,13 +937,17 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ type: 'category', + display: false, stacked: true }], yAxes: [{ - type: 'linear' + type: 'linear', + display: false }] } } @@ -997,12 +996,16 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ type: 'linear', + display: false, stacked: true }] } @@ -1054,12 +1057,16 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ type: 'linear', + display: false, stacked: true }] } @@ -1109,13 +1116,17 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ + type: 'linear', + display: false, stacked: true, - type: 'linear' }] } } @@ -1151,13 +1162,17 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ - type: 'category' + type: 'category', + display: false }], yAxes: [{ - stacked: true, - type: 'linear' + type: 'linear', + display: false, + stacked: true }] } } @@ -1190,14 +1205,18 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { xAxes: [{ type: 'category', + display: false, stacked: true, barPercentage: 1, }], yAxes: [{ type: 'logarithmic', + display: false, stacked: true }] } diff --git a/test/specs/controller.bubble.tests.js b/test/specs/controller.bubble.tests.js index 6589afa12dd..4799883ddfb 100644 --- a/test/specs/controller.bubble.tests.js +++ b/test/specs/controller.bubble.tests.js @@ -1,25 +1,4 @@ describe('Chart.controllers.bubble', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - }, - scale: { - display: false - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'bubble', @@ -140,12 +119,16 @@ describe('Chart.controllers.bubble', 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 }] } } diff --git a/test/specs/controller.doughnut.tests.js b/test/specs/controller.doughnut.tests.js index 12bc14a8fec..85e382ac3f9 100644 --- a/test/specs/controller.doughnut.tests.js +++ b/test/specs/controller.doughnut.tests.js @@ -1,22 +1,4 @@ describe('Chart.controllers.doughnut', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'doughnut', @@ -86,6 +68,8 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1', 'label2', 'label3'] }, options: { + legend: false, + title: false, animation: { animateRotate: true, animateScale: false @@ -187,6 +171,8 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1'] }, options: { + legend: false, + title: false, cutoutPercentage: 50, rotation: Math.PI, circumference: Math.PI * 0.5, diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index 94b4fd88fef..31c0763a8fe 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -1,25 +1,4 @@ describe('Chart.controllers.line', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - }, - scale: { - display: false - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'line', @@ -195,6 +174,8 @@ describe('Chart.controllers.line', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { point: { backgroundColor: 'red', @@ -203,10 +184,12 @@ describe('Chart.controllers.line', function() { }, scales: { xAxes: [{ - id: 'firstXScaleID' + id: 'firstXScaleID', + display: false }], yAxes: [{ - id: 'firstYScaleID' + id: 'firstYScaleID', + display: false }] } }, @@ -254,11 +237,17 @@ describe('Chart.controllers.line', function() { }] }, options: { + legend: false, + title: false, hover: { mode: 'single' }, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, ticks: { beginAtZero: true } @@ -320,8 +309,14 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } @@ -372,12 +367,19 @@ describe('Chart.controllers.line', 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 }] } } @@ -447,8 +449,14 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } @@ -495,8 +503,14 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { + legend: false, + title: false, scales: { + xAxes: [{ + display: false, + }], yAxes: [{ + display: false, stacked: true }] } diff --git a/test/specs/controller.polarArea.tests.js b/test/specs/controller.polarArea.tests.js index 2d8c48f3233..050bd68b80f 100644 --- a/test/specs/controller.polarArea.tests.js +++ b/test/specs/controller.polarArea.tests.js @@ -1,25 +1,4 @@ describe('Chart.controllers.polarArea', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - }, - scale: { - display: false - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('should be constructed', function() { var chart = window.acquireChart({ type: 'polarArea', @@ -102,6 +81,8 @@ describe('Chart.controllers.polarArea', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { arc: { backgroundColor: 'rgb(255, 0, 0)', @@ -183,6 +164,8 @@ describe('Chart.controllers.polarArea', function() { }, options: { showLines: true, + legend: false, + title: false, startAngle: 0, // default is -0.5 * Math.PI elements: { arc: { diff --git a/test/specs/controller.radar.tests.js b/test/specs/controller.radar.tests.js index 2e4b28d1e24..df1001420c4 100644 --- a/test/specs/controller.radar.tests.js +++ b/test/specs/controller.radar.tests.js @@ -1,25 +1,4 @@ describe('Chart.controllers.radar', function() { - - beforeAll(function() { - // set global test options - this._defaults = jasmine.overrideDefaults({ - global: { - plugins: { - legend: false, - title: false - } - }, - scale: { - display: false - } - }); - }); - - afterAll(function() { - // restore default chart config - jasmine.overrideDefaults(this._defaults); - }); - it('Should be constructed', function() { var chart = window.acquireChart({ type: 'radar', @@ -100,6 +79,8 @@ describe('Chart.controllers.radar', function() { }, options: { showLines: true, + legend: false, + title: false, elements: { line: { backgroundColor: 'rgb(255, 0, 0)', @@ -171,7 +152,7 @@ describe('Chart.controllers.radar', function() { meta.controller.update(); [ - {x: 256, y: 116, cppx: 246, cppy: 116, cpnx: 272, cpny: 116}, + {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}, @@ -228,7 +209,7 @@ describe('Chart.controllers.radar', function() { // Since tension is now 0, we don't care about the control points [ - {x: 256, y: 116}, + {x: 256, y: 117}, {x: 464, y: 256}, {x: 256, y: 256}, {x: 200, y: 256}, @@ -287,11 +268,11 @@ describe('Chart.controllers.radar', function() { })); expect(meta.data[0]._model.x).toBeCloseToPixel(256); - expect(meta.data[0]._model.y).toBeCloseToPixel(116); + expect(meta.data[0]._model.y).toBeCloseToPixel(117); expect(meta.data[0]._model.controlPointPreviousX).toBeCloseToPixel(241); - expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(116); + expect(meta.data[0]._model.controlPointPreviousY).toBeCloseToPixel(117); expect(meta.data[0]._model.controlPointNextX).toBeCloseToPixel(281); - expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(116); + expect(meta.data[0]._model.controlPointNextY).toBeCloseToPixel(117); expect(meta.data[0]._model).toEqual(jasmine.objectContaining({ radius: 2.2, backgroundColor: 'rgb(0, 1, 3)',