Skip to content

Commit

Permalink
Merge pull request #10706 from s4m0r4m4/master
Browse files Browse the repository at this point in the history
Fixed #10664 - The "plugins" property is not assigned when creating the Chart object
  • Loading branch information
yigitfindikli authored Oct 13, 2021
2 parents fe081ba + 6b533e1 commit 0e423b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/app/components/chart/chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('UIChart', () => {

let chart: UIChart;
let fixture: ComponentFixture<UIChart>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
Expand All @@ -23,7 +22,7 @@ describe('UIChart', () => {
});

it('should created', () => {
chart.data = {
const testData = {
datasets: [{
data: [
11,
Expand All @@ -49,12 +48,24 @@ describe('UIChart', () => {
"Blue"
]
};
chart.type = "polarArea";

chart.data = testData;
const chartType = "polarArea";
chart.type = chartType;
const testPlugin = { id: 'test-plugin' };
chart.plugins = [testPlugin];
const testOptions = { test: '123' };
chart.options = {...testOptions};
fixture.detectChanges();

expect(fixture.debugElement.query(By.css("canvas"))).toBeTruthy();

expect(chart.chart.config.type).toEqual(chartType);
expect(chart.chart.data).toEqual(testData);
expect(chart.chart.config.plugins).toContain(testPlugin);
});


it('should call onCanvasClick', () => {
chart.data = {
datasets: [{
Expand Down Expand Up @@ -85,7 +96,7 @@ describe('UIChart', () => {
chart.height = '200px';
chart.width = '200px';
chart.type = "polarArea";
const canvasOnClickSpy = spyOn(chart,"onCanvasClick").and.callThrough();
const canvasOnClickSpy = spyOn(chart, "onCanvasClick").and.callThrough();
const canvas = fixture.debugElement.query(By.css("canvas"));
fixture.detectChanges();

Expand Down
3 changes: 2 additions & 1 deletion src/app/components/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export class UIChart implements AfterViewInit, OnDestroy {
this.chart = new Chart(this.el.nativeElement.children[0].children[0], {
type: this.type,
data: this.data,
options: this.options
options: this.options,
plugins: this.plugins
});
}

Expand Down

0 comments on commit 0e423b6

Please sign in to comment.