23 lines
831 B
TypeScript
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);
|
|
});
|
|
});
|