Skip to content

Commit

Permalink
feat: create maintenance vars test
Browse files Browse the repository at this point in the history
for ForecastParameters file
  • Loading branch information
zz-hh-aa committed Nov 22, 2024
1 parent 19b6eb8 commit 73e5077
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/models/ForecastParameters.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createForecastParameters, DEFAULT_FORECAST_PARAMETERS } from "./ForecastParameters";

it("can create default forecast parameters", () => {
const params = createForecastParameters(DEFAULT_FORECAST_PARAMETERS.maintenancePercentage);
expect(params).toBeDefined();
});

it("correctly sets maintenance percentage while keeping defaults", () => {
const customMaintenance = 0.015;
const params = createForecastParameters(customMaintenance);

expect(params.maintenancePercentage).toBe(customMaintenance);
expect(params.incomeGrowthPerYear).toBe(DEFAULT_FORECAST_PARAMETERS.incomeGrowthPerYear);
expect(params.rentGrowthPerYear).toBe(DEFAULT_FORECAST_PARAMETERS.rentGrowthPerYear);
expect(params.constructionPriceGrowthPerYear).toBe(DEFAULT_FORECAST_PARAMETERS.constructionPriceGrowthPerYear);
expect(params.propertyPriceGrowthPerYear).toBe(DEFAULT_FORECAST_PARAMETERS.propertyPriceGrowthPerYear);
expect(params.yearsForecast).toBe(DEFAULT_FORECAST_PARAMETERS.yearsForecast);
expect(params.affordabilityThresholdIncomePercentage).toBe(DEFAULT_FORECAST_PARAMETERS.affordabilityThresholdIncomePercentage);
});

it("handles different maintenance percentage values", () => {
const testCases = [0.015, 0.02, 0.0375];

testCases.forEach(maintenance => {
const params = createForecastParameters(maintenance);
expect(params.maintenancePercentage).toBe(maintenance);
});
});

0 comments on commit 73e5077

Please sign in to comment.