From 8811996f640bb208ae7df872d48ac11c10231947 Mon Sep 17 00:00:00 2001 From: Seth Posner Date: Mon, 13 Nov 2023 14:10:00 -0800 Subject: [PATCH] Add tests confirming low-input conversion values --- tests/features/conversions.test.ts | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/features/conversions.test.ts b/tests/features/conversions.test.ts index 09d6569..58e2e99 100644 --- a/tests/features/conversions.test.ts +++ b/tests/features/conversions.test.ts @@ -47,6 +47,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.currentGain)).compare_tolerance(100); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.currentGain)).compare_tolerance(0); + }); }); describe("Calculates actualGain correctly", () => { let conversion: GenericConversion; @@ -69,6 +73,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.actualGain)).compare_tolerance(100); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.actualGain)).compare_tolerance(0); + }); }); describe("Calculates currentAt correctly", () => { let conversion: GenericConversion; @@ -95,6 +103,10 @@ describe("Creating conversion", () => { Decimal.pow(100, 2).times(10) ); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.currentAt)).compare_tolerance(0); + }); }); describe("Calculates nextAt correctly", () => { let conversion: GenericConversion; @@ -117,6 +129,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.nextAt)).compare_tolerance(Decimal.pow(101, 2).times(10)); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.nextAt)).compare_tolerance(Decimal.dTen); + }); }); test("Converts correctly", () => { const conversion = createCumulativeConversion(() => ({ @@ -193,6 +209,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.currentGain)).compare_tolerance(100); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.currentGain)).compare_tolerance(1); + }); }); describe("Calculates actualGain correctly", () => { let conversion: GenericConversion; @@ -216,6 +236,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.actualGain)).compare_tolerance(99); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.actualGain)).compare_tolerance(0); + }); }); describe("Calculates currentAt correctly", () => { let conversion: GenericConversion; @@ -243,6 +267,10 @@ describe("Creating conversion", () => { Decimal.pow(100, 2).times(10) ); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.currentAt)).compare_tolerance(Decimal.pow(1, 2).times(10)); + }); }); describe("Calculates nextAt correctly", () => { let conversion: GenericConversion; @@ -266,6 +294,10 @@ describe("Creating conversion", () => { baseResource.value = Decimal.pow(100, 2).times(10).add(1); expect(unref(conversion.nextAt)).compare_tolerance(Decimal.pow(101, 2).times(10)); }); + test("Zero", () => { + baseResource.value = Decimal.dZero; + expect(unref(conversion.nextAt)).compare_tolerance(Decimal.pow(2, 2).times(10)); + }); }); test("Converts correctly", () => { const conversion = createIndependentConversion(() => ({