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 19, 2024
1 parent 1165f10 commit 8abe6a2
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(browserZoomFactor => {
it(`should scale chart height appropriately if the browser zoom factor is ${browserZoomFactor}`, () => {
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, browserZoomFactor);

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

Expand Down

0 comments on commit 8abe6a2

Please sign in to comment.