diff --git a/src/app/carbon-estimation/carbon-estimation.component.spec.ts b/src/app/carbon-estimation/carbon-estimation.component.spec.ts index 280cd422..20c17bc6 100644 --- a/src/app/carbon-estimation/carbon-estimation.component.spec.ts +++ b/src/app/carbon-estimation/carbon-estimation.component.spec.ts @@ -49,20 +49,27 @@ describe('CarbonEstimationComponent', () => { it('should set chart height when inner height is more than base height', () => { spyOnProperty(component.detailsPanel.nativeElement, 'clientHeight').and.returnValue(200); + const innerHeight = 1000; + spyOnProperty(window, 'innerHeight').and.returnValue(innerHeight); + component.ngOnInit(); fixture.detectChanges(); - expect(component.chartOptions.chart.height).toBe(600 - estimatorBaseHeight - 200); + console.log(`window.innerHeight: ${window.innerHeight}`); + expect(component.chartOptions.chart.height).toBe(innerHeight - estimatorBaseHeight - 200); }); it('should set chart height to value if inner height more than base height plus extra height', () => { spyOnProperty(component.detailsPanel.nativeElement, 'clientHeight').and.returnValue(200); + const innerHeight = 1000; + spyOnProperty(window, 'innerHeight').and.returnValue(innerHeight); + fixture.componentRef.setInput('extraHeight', '100'); fixture.detectChanges(); component.ngOnInit(); fixture.detectChanges(); - expect(component.chartOptions.chart.height).toBe(600 - estimatorBaseHeight - 200 - 100); + expect(component.chartOptions.chart.height).toBe(innerHeight - estimatorBaseHeight - 200 - 100); }); it('should recalculate chart height on window resize, for laptop screen', () => {