Skip to content

Commit

Permalink
Add a test covering metaset behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkel committed Oct 13, 2021
1 parent adceef9 commit 44094c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/core.controller.js
Expand Up @@ -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);

Expand Down
24 changes: 22 additions & 2 deletions test/specs/core.controller.tests.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 44094c3

Please sign in to comment.