Skip to content

Commit

Permalink
Update remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jantoun-scottlogic committed Jun 20, 2024
1 parent 2a90b42 commit 76ec8b0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/carbon-estimation/carbon-estimation.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 76ec8b0

Please sign in to comment.