Skip to content

Commit

Permalink
Parameterise browser zoom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jantoun-scottlogic committed Jun 18, 2024
1 parent 4803b48 commit 2521abe
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/app/carbon-estimation/carbon-estimation.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ describe('CarbonEstimationComponent', () => {
});
});

it('should scale chart height according to browser zoom factor', () => {
spyOn(component.chart as ChartComponent, 'updateOptions');
spyOnProperty(component.detailsPanel.nativeElement, 'clientHeight').and.returnValue(200);
[0.5, 1, 2, 5].forEach(zoomFactor => {
it('should scale chart height according to browser zoom factor', () => {
spyOn(component.chart as ChartComponent, 'updateOptions');
spyOnProperty(component.detailsPanel.nativeElement, 'clientHeight').and.returnValue(200);

component.onResize(1500, 1000, 2000, 2);
component.onResize(1500, 1000, 2000, zoomFactor);

expect(component.chart?.updateOptions).toHaveBeenCalledOnceWith({
chart: { height: (1500 - estimatorBaseHeight - 200) * 2 },
expect(component.chart?.updateOptions).toHaveBeenCalledOnceWith({
chart: { height: (1500 - estimatorBaseHeight - 200) * zoomFactor },
});
});
});

Expand Down

0 comments on commit 2521abe

Please sign in to comment.