-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check to colors plugin if defaults are set (#11927)
- Loading branch information
1 parent
5d2dfbe
commit 3f2968c
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
describe('Plugin.colors', () => { | ||
describe('auto', jasmine.fixture.specs('plugin.colors')); | ||
|
||
describe('Plugin.colors.chartDefaults', () => { | ||
beforeAll(() => { | ||
Chart.defaults.backgroundColor = ['green', 'yellow']; | ||
}); | ||
|
||
afterAll(() => { | ||
Chart.defaults.backgroundColor = 'rgba(0,0,0,0.1)'; | ||
}); | ||
|
||
it('should not use colors plugin when chart defaults are given', () => { | ||
const chart = window.acquireChart({ | ||
type: 'bar', | ||
data: { | ||
datasets: [{ | ||
data: [1, 10], | ||
label: 'dataset1' | ||
}], | ||
labels: ['label1', 'label2'] | ||
}, | ||
options: { | ||
plugins: { | ||
colors: { | ||
enabled: true | ||
} | ||
} | ||
} | ||
}); | ||
|
||
const meta = chart.getDatasetMeta(0); | ||
expect(meta.data[0].options.backgroundColor).toBe('green'); | ||
expect(meta.data[1].options.backgroundColor).toBe('yellow'); | ||
}); | ||
}); | ||
}); |