Files
rk-backend/src/graphics/elements/drawWarnung.spec.ts
T
2026-10-26 07:34:23 +01:00

25 lines
1.3 KiB
TypeScript

import { describe, expect, it } from '@jest/globals';
import { DrawWarnung, parseWarnungRequest } from './drawWarnung';
describe('Warnung ohne MinMax', () => {
it('liefert die Originalgeometrie als SVG, XAML und UTF-8-Base64', () => {
const { config, options } = parseWarnungRequest({ config: {} });
const result = new DrawWarnung().getObject(config, options);
expect(result.width).toBe(20);
expect(result.height).toBe(20);
expect(result.varianten).toHaveLength(1);
const variant = result.varianten[0];
expect(variant.svg).toContain('fill="#FAC44F" fill-rule="evenodd"');
expect(variant.xaml).toContain('FillRule="EvenOdd"');
expect(variant.xaml).toContain('Width="20" Height="20"');
expect(Buffer.from(variant.xamlBase64, 'base64').toString('utf8')).toBe(variant.xaml);
});
it('übernimmt Größe und Farbe', () => {
const { config, options } = parseWarnungRequest({ config: { width: 40, height: 30 }, options: { color: '#FF0000' } });
expect(new DrawWarnung().getObject(config, options).varianten[0].svg).toContain('fill="#FF0000"');
});
it.each([null, {}, { config: { width: -1 } }, { config: {}, options: { color: '<script>' } }])('weist ungültige Parameter zurück', input => {
expect(() => parseWarnungRequest(input)).toThrow();
});
});