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 ? '' : { 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(''); 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' }); }); });