Files
portal/app/tests/Frontend/imageRule.spec.ts
T
Дмитрий 8cd2ef91d3 feat(реклама яндекс): клиентские проверки лимитов креатива объявления
Три изолированных модуля по TDD (тест до кода) — заголовок/второй
заголовок/текст (creativeLimits.ts), проверка ссылки (urlRule.ts) и
проверка картинки (imageRule.ts + imageMeta.ts). Цифры и сообщения —
порт 1:1 из app/app/Services/Advertising/CreativeValidator.php
(единый источник лимитов Яндекс.Директа). 23 новых теста зелёные.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 20:32:58 +03:00

30 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { checkImage } from '../../resources/js/lib/advertising/imageRule';
describe('imageRule — checkImage', () => {
it('пропускает 500×500 png весом 1 КБ', () => {
const result = checkImage({ width: 500, height: 500, bytes: 1024, mime: 'image/png' });
expect(result).toBeNull();
});
it('отклоняет картинку меньше минимума 450×450', () => {
const result = checkImage({ width: 449, height: 500, bytes: 1024, mime: 'image/png' });
expect(result).toMatch(/450/);
});
it('отклоняет картинку тяжелее 10 МБ', () => {
const result = checkImage({
width: 500,
height: 500,
bytes: 11 * 1024 * 1024,
mime: 'image/png',
});
expect(result).toMatch(/10/);
});
it('отклоняет недопустимый формат (webp)', () => {
const result = checkImage({ width: 500, height: 500, bytes: 1024, mime: 'image/webp' });
expect(result).toMatch(/формат/i);
});
});