templates2.Base.Next/tests/unit/plans.test.ts
w4c-templates 219be916cb
Some checks are pending
CI / quality (push) Waiting to run
chore(template): publish Base.Next
2026-10-11 23:23:30 +03:00

23 lines
831 B
TypeScript

import { describe, expect, it } from 'vitest';
import { getPlan, isPlanId, PLANS, withinLimit } from '@/lib/plans';
describe('plans', () => {
it('recognises valid plan ids only', () => {
expect(isPlanId('free')).toBe(true);
expect(isPlanId('pro')).toBe(true);
expect(isPlanId('enterprise')).toBe(false);
expect(isPlanId(undefined)).toBe(false);
});
it('falls back to the free plan for unknown values', () => {
expect(getPlan('nonsense').id).toBe('free');
expect(getPlan('pro').id).toBe('pro');
});
it('enforces usage limits inclusively below the cap', () => {
expect(withinLimit('free', 'seats', PLANS.free.limits.seats - 1)).toBe(true);
expect(withinLimit('free', 'seats', PLANS.free.limits.seats)).toBe(false);
expect(withinLimit('pro', 'apiCalls', 50_000)).toBe(true);
});
});