import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChartModalComponent } from './chart.modal'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { FEATURE_IMPORTANCE } from '../../../../mockup'; const chart = { chartOptions: { tooltip: { type: 'axis', backgroundColor: '#FFF', borderColor: '#ccc', borderWidth: 1, textStyle: { color: '#000', }, formatter: '{b}: {c}%', }, grid: { width: '95%', left: 0, top: '0', containLabel: true, }, legend: { show: false }, title: { show: false }, }, xAxis: { show: true, type: 'value', position: 'top', axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: true }, splitNumber: 2, axisLabel: { fontFamily: 'NotosansFont', fontSize: 12, fontStyle: 'italic', }, }, yAxis: { type: 'category', inverse: true, data: FEATURE_IMPORTANCE.categories, axisLine: { show: false }, axisTick: { show: false }, axisLabel: { fontFamily: 'NotosansFont', fontSize: 12, }, }, series: [ { type: 'bar', cursor: 'auto', barWidth: 16, itemStyle: { color: '#42A5F5' }, label: { show: false, }, data: FEATURE_IMPORTANCE.data, }, ], }; describe('FeatureImportanceModal', () => { let component: ChartModalComponent; let fixture: ComponentFixture; beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ChartModalComponent], providers: [BsModalRef], imports: [], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(ChartModalComponent); component = fixture.componentInstance; component.data = { chart, title: 'Feature Importance' }; component.bsModalRef = new BsModalRef(); component.bsModalRef.hide = jest.fn(); fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should fire bsRef hide method onClose', () => { component.onClose(); expect(component.bsModalRef.hide).toHaveBeenCalled(); }); });