diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/utils/math/calculate-extrapolated-value.test.ts b/src/Umbraco.Web.UI.Client/src/packages/core/utils/math/calculate-extrapolated-value.test.ts new file mode 100644 index 0000000000..b5b3024f61 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/utils/math/calculate-extrapolated-value.test.ts @@ -0,0 +1,21 @@ +import { expect } from '@open-wc/testing'; +import { calculateExtrapolatedValue } from './math.js'; + +describe('calculateExtrapolatedValue', () => { + it('should return NaN if the increase factor is less than 0', () => { + expect(calculateExtrapolatedValue(1, -1)).to.be.NaN; + }); + + it('should return NaN if the increase factor is equal to 1', () => { + expect(calculateExtrapolatedValue(1, 1)).to.be.NaN; + }); + + it('should return the extrapolated value', () => { + expect(calculateExtrapolatedValue(1, 0)).to.equal(1); + expect(calculateExtrapolatedValue(1, 0.3)).to.equal(1.4285714285714286); + expect(calculateExtrapolatedValue(2, 0.5)).to.equal(4); + expect(calculateExtrapolatedValue(3, 0.6)).to.equal(7.5); + expect(calculateExtrapolatedValue(100, 0.2)).to.equal(125); + expect(calculateExtrapolatedValue(500, 0.99)).to.equal(49999.999999999956); + }); +});