feat: unavailable addons support

This commit is contained in:
2026-08-17 21:58:11 +07:00
parent f2940e55bd
commit 33d35d91e6
7 changed files with 45 additions and 9 deletions

View File

@@ -14,8 +14,8 @@ import type { AddonData, PricingPlans } from '../types';
const pricing: PricingPlans = {
device_price: 100,
addons: [
{ id: 'a', name: 'A', price: 50, free_threshold: -1 },
{ id: 'b', name: 'B', price: 30, free_threshold: -1 },
{ id: 'a', name: 'A', price: 50, free_threshold: -1, is_enabled: true },
{ id: 'b', name: 'B', price: 30, free_threshold: -1, is_enabled: true },
],
};
@@ -38,8 +38,8 @@ describe('sumAddonPrices', () => {
it('makes addons free at their device threshold but keeps -1 paid', () => {
const thresholdAddons: AddonData[] = [
{ id: 'threshold', name: 'Threshold', price: 50, free_threshold: 6 },
{ id: 'paid', name: 'Paid', price: 30, free_threshold: -1 },
{ id: 'threshold', name: 'Threshold', price: 50, free_threshold: 6, is_enabled: true },
{ id: 'paid', name: 'Paid', price: 30, free_threshold: -1, is_enabled: true },
];
expect(sumAddonPrices(thresholdAddons, ['threshold', 'paid'], 5)).toBe(80);