templates2.Admin.Next/tests/unit/plans.test.ts
w4c-templates c64f7ffa9e
Some checks failed
CI / quality (push) Has been cancelled
chore(template): publish Admin.Next
2026-10-11 23:25:34 +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);
});
});