diff --git a/src/core/core.controller.js b/src/core/core.controller.js index bf23252780f..b9376617eb2 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -916,7 +916,7 @@ class Chart { _remove('resize', listener); - // Stop animating and remove metasets, so when re-attached, the animations start from begining. + // Stop animating and remove metasets, so when re-attached, the animations start from beginning. this._stop(); this._resize(0, 0); diff --git a/test/specs/core.controller.tests.js b/test/specs/core.controller.tests.js index cb4eba08c07..48c1586a8cd 100644 --- a/test/specs/core.controller.tests.js +++ b/test/specs/core.controller.tests.js @@ -1121,7 +1121,7 @@ describe('Chart', function() { }); }); - it('should resize the canvas if attached to the DOM after construction with mutiple parents', function(done) { + it('should resize the canvas if attached to the DOM after construction with multiple parents', function(done) { var canvas = document.createElement('canvas'); var wrapper = document.createElement('div'); var wrapper2 = document.createElement('div'); @@ -1848,7 +1848,7 @@ describe('Chart', function() { expect(metasets[2].order).toEqual(3); expect(metasets[3].order).toEqual(4); }); - it('should be moved when datasets are removed from begining', function() { + it('should be moved when datasets are removed from beginning', function() { this.chart.data.datasets.splice(0, 2); this.chart.update(); const metasets = this.chart._metasets; @@ -1910,6 +1910,26 @@ describe('Chart', function() { }); }); + describe('_destroyDatasetMeta', function() { + beforeEach(function() { + this.chart = acquireChart({ + type: 'line', + data: { + datasets: [ + {label: '1', order: 2}, + {label: '2', order: 1}, + {label: '3', order: 4}, + {label: '4', order: 3}, + ] + } + }); + }); + it('cleans up metasets when the chart is destroyed', function() { + this.chart.destroy(); + expect(this.chart._metasets.length).toHaveSize(0); + }); + }); + describe('data visibility', function() { it('should hide a dataset', function() { var chart = acquireChart({