You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
canChoosePlan,
|
|
PRICING_COMPARE_VALUE,
|
|
PRICING_PLAN_REASON,
|
|
type PricingPlanState
|
|
} from './plan-state';
|
|
|
|
const ALL: PricingPlanState[] = ['available', 'current', 'selected'];
|
|
|
|
describe('pricing plan state', () => {
|
|
it('only the current plan is unchoosable', () => {
|
|
expect(ALL.filter((s) => !canChoosePlan(s))).toEqual(['current']);
|
|
});
|
|
|
|
it('every state that blocks has a sentence', () => {
|
|
// The point of the exhaustive Record: a blocked state that says nothing is
|
|
// the hole the doctrine exists to close.
|
|
for (const state of ALL) {
|
|
if (!canChoosePlan(state)) {
|
|
expect(PRICING_PLAN_REASON[state], `${state} blocks and must explain`).toBeTruthy();
|
|
}
|
|
}
|
|
});
|
|
|
|
it('a state that does NOT block says nothing', () => {
|
|
for (const state of ALL) {
|
|
if (canChoosePlan(state)) {
|
|
expect(PRICING_PLAN_REASON[state], `${state} is open — no sentence`).toBeNull();
|
|
}
|
|
}
|
|
});
|
|
|
|
it('every sentence is an idlangref with an English fallback', () => {
|
|
for (const ref of Object.values(PRICING_PLAN_REASON)) {
|
|
if (ref === null) continue;
|
|
expect(ref.startsWith('#?'), ref).toBe(true);
|
|
const [key, fallback] = ref.slice(2).split('|');
|
|
expect(key.startsWith('blocks.pricing.'), key).toBe(true);
|
|
expect(fallback?.length, `${key} needs a fallback`).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it('the Record covers the union and nothing else', () => {
|
|
expect(Object.keys(PRICING_PLAN_REASON).sort()).toEqual([...ALL].sort());
|
|
});
|
|
});
|
|
|
|
describe('pricing comparison cell words', () => {
|
|
it('covers BOTH booleans — a glyph says nothing to a screen reader', () => {
|
|
expect(Object.keys(PRICING_COMPARE_VALUE).sort()).toEqual(['false', 'true']);
|
|
});
|
|
|
|
it('every word is an idlangref under the block namespace with a fallback', () => {
|
|
for (const ref of Object.values(PRICING_COMPARE_VALUE)) {
|
|
expect(ref.startsWith('#?'), ref).toBe(true);
|
|
const [key, fallback] = ref.slice(2).split('|');
|
|
expect(key.startsWith('blocks.pricing.'), key).toBe(true);
|
|
expect(fallback?.length, `${key} needs a fallback`).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it('the two cases do not share a sentence', () => {
|
|
expect(PRICING_COMPARE_VALUE.true).not.toBe(PRICING_COMPARE_VALUE.false);
|
|
});
|
|
});
|