mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #36711 from overleaf/oa-prices
[web] Prices, their versions and helper functions GitOrigin-RevId: b42f16fe3b083a4872230f2e348b247650d08df8
This commit is contained in:
+13
-7
@@ -1,17 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
annualSavings,
|
||||
roundedTwelfth,
|
||||
} from '../../../../app/src/Features/Subscription/PlansHelper.mjs'
|
||||
getRoundedTwelfth,
|
||||
} from '../../../../app/src/Features/Subscription/PriceVersions.mjs'
|
||||
|
||||
describe('PlansHelper', function () {
|
||||
describe('roundedTwelfth', function () {
|
||||
it('divides by twelve when the result is already a multiple of 0.05', function () {
|
||||
const roundedTwelfth = getRoundedTwelfth('feb2026')
|
||||
expect(roundedTwelfth(120)).to.equal(10)
|
||||
expect(roundedTwelfth(180)).to.equal(15)
|
||||
})
|
||||
|
||||
it('rounds up to the nearest 0.05 for display', function () {
|
||||
const roundedTwelfth = getRoundedTwelfth('feb2026')
|
||||
// 263 / 12 = 21.9166… -> 21.95
|
||||
expect(roundedTwelfth(263)).to.equal(21.95)
|
||||
// 505 / 12 = 42.0833… -> 42.1
|
||||
@@ -19,12 +21,13 @@ describe('PlansHelper', function () {
|
||||
})
|
||||
|
||||
it('rounds up to the nearest 0.25 when given a 0.25 increment', function () {
|
||||
const roundedTwelfth = getRoundedTwelfth('aug2026')
|
||||
// 159 / 12 = 13.25 -> already a multiple of 0.25
|
||||
expect(roundedTwelfth(159, 0.25)).to.equal(13.25)
|
||||
expect(roundedTwelfth(159)).to.equal(13.25)
|
||||
// 76 / 12 = 6.3333… -> 6.5
|
||||
expect(roundedTwelfth(76, 0.25)).to.equal(6.5)
|
||||
expect(roundedTwelfth(76)).to.equal(6.5)
|
||||
// 319 / 12 = 26.5833… -> 26.75
|
||||
expect(roundedTwelfth(319, 0.25)).to.equal(26.75)
|
||||
expect(roundedTwelfth(319)).to.equal(26.75)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -37,13 +40,16 @@ describe('PlansHelper', function () {
|
||||
})
|
||||
|
||||
it('ignores the rounding applied to the displayed per-month price', function () {
|
||||
let roundedTwelfth = getRoundedTwelfth('feb2026')
|
||||
// 100/year displays as 8.35 or 8.50 a month depending on the increment;
|
||||
// rounding up understates the saving, so neither stands in for it
|
||||
expect(annualSavings(10, 100)).to.be.greaterThan(
|
||||
1 - roundedTwelfth(100, 0.05) / 10
|
||||
1 - roundedTwelfth(100) / 10
|
||||
)
|
||||
|
||||
roundedTwelfth = getRoundedTwelfth('aug2026')
|
||||
expect(annualSavings(10, 100)).to.be.greaterThan(
|
||||
1 - roundedTwelfth(100, 0.25) / 10
|
||||
1 - roundedTwelfth(100) / 10
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1232,7 +1232,8 @@ describe('SubscriptionViewModelBuilder', function () {
|
||||
const { plans } =
|
||||
ctx.SubscriptionViewModelBuilder.buildPlansListForSubscriptionDash(
|
||||
undefined,
|
||||
false
|
||||
false,
|
||||
{}
|
||||
)
|
||||
assert.isTrue(plans.every(plan => plan.listPrice === undefined))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user