Files
portal/app/tests/Frontend/pricingTiers.spec.ts
T
Дмитрий 77050dbefb fix(admin): клиентский диапазон ступеней в тарифной сетке + предпросмотр в редакторе
Cherry-pick a7a4e735 поверх боевой ветки feat/portal-mobile-adaptive для
выката ТОЛЬКО правки тарифов на прод. Логика денег не менялась.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 15:29:40 +03:00

43 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest';
import { tierRangeText } from '../../resources/js/utils/pricingTiers';
/**
* Единый источник истины для «ширина ступени → накопительный диапазон».
* Числа — ровно те, что клиент видит в кабинете (боевая сетка 08.07.2026):
* ширины 250/500/1000/2500/5000/10000/∞ → 1250, 251750, …, 19251+.
*/
const tiers = [
{ leads_in_tier: 250 },
{ leads_in_tier: 500 },
{ leads_in_tier: 1000 },
{ leads_in_tier: 2500 },
{ leads_in_tier: 5000 },
{ leads_in_tier: 10000 },
{ leads_in_tier: null },
];
describe('tierRangeText', () => {
it('первая ступень начинается с 1', () => {
expect(tierRangeText(tiers, 0)).toBe('1250');
});
it('вторая ступень — накопительный диапазон, а не «сама ширина»', () => {
expect(tierRangeText(tiers, 1)).toBe('251750');
});
it('третья ступень продолжает накопление', () => {
expect(tierRangeText(tiers, 2)).toBe('7511750');
});
it('шестая ступень', () => {
// 250+500+1000+2500 = 4250 → пятая 42519250 → шестая 925119250
expect(tierRangeText(tiers, 5)).toBe('925119250');
});
it('последняя ступень (leads_in_tier=null) — открытый диапазон со знаком +', () => {
// 250+500+1000+2500+5000+10000 = 19250 → tier 7 стартует с 19251
expect(tierRangeText(tiers, 6)).toBe('19251+');
});
});