templates2.Store.Nuxt/tests/unit/plans.test.ts
w4c-templates 228f2f01f2
Some checks failed
CI / quality (push) Has been cancelled
chore(template): publish Store.Nuxt
2026-10-11 23:24:30 +03:00

23 lines
833 B
TypeScript

import { describe, expect, it } from 'vitest';
import { getPlan, isPlanId, PLANS, withinLimit } from '#shared/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);
});
});