procon aggregate

This commit is contained in:
marco committed 2026-10-22 07:57:46 +02:00
1 parent e284fae7b4
commit d0655f3638
32 files changed
+1520 -1058

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, it, jest } from '@jest/globals';
jest.mock('./draw.service', () => ({ DrawService: class DrawService {} }));
import { DrawController } from './draw.controller';
import { DrawService } from './draw.service';
describe('DrawController Endpunkte', () => {
const types = ['gurtfoerderer', 'setzmaschine', 'band', 'brecher', 'behaelter', 'sieb',
'siebentwaesserung', 'weiche', 'zyklon', 'turbowascher', 'haspel', 'pumpe',
'ventil', 'wasserZufuhr', 'behaelterMulti', 'motor', 'silo', 'flex'];
it.each(types)('leitet %s mit unveränderten Optionen an den Generator weiter', type => {
const generator = jest.fn((_options: unknown, raw: boolean) => raw ? '<svg/>' : { name: type });
const controller = new DrawController({ [type]: generator } as unknown as DrawService);
const options = { state: 'active' as const, scale: 2 };
expect(controller.getGraphicData(type, options)).toEqual({ name: type });
expect(generator).toHaveBeenLastCalledWith(options, false);
expect(controller.getGraphicSvg(type, options)).toBe('<svg/>');
expect(generator).toHaveBeenLastCalledWith(options, true);
});
it.each(['unbekannt', 'constructor', 'toString', '__proto__'])('weist unbekannte Grafiktypen zurück: %s', type => {
const controller = new DrawController({} as DrawService);
expect(() => controller.getGraphicData(type, {})).toThrow('Unbekannter Grafiktyp');
expect(() => controller.getGraphicSvg(type, {})).toThrow('Unbekannter Grafiktyp');
});
it('behält graphic und anlageDurmin bei', () => {
const gurtfoerderer = jest.fn(() => ({ name: 'gurtfoerderer' }));
const getAnlageDurmin = jest.fn(() => ({ name: 'anlage' }));
const controller = new DrawController({ gurtfoerderer, getAnlageDurmin } as unknown as DrawService);
expect(controller.getGraphic({})).toEqual({ name: 'gurtfoerderer' });
expect(controller.getAnlageDurmin()).toEqual({ name: 'anlage' });
});
});