import { Point } from '@flatten-js/core'; import { describe, expect, it } from 'vitest'; import type { DrawController } from '../drawControllers/DrawController'; import { ImageEntity } from './ImageEntity'; /** drawLine·drawImage 호출만 세는 최소 컨트롤러. */ function countingController() { const calls = { lines: 0, images: 0 }; const controller = { setLineStyles: () => {}, drawLine: () => { calls.lines += 1; }, drawImage: () => { calls.images += 1; }, } as unknown as DrawController; return { controller, calls }; } function entity(): ImageEntity { const image = { currentSrc: 'data:image/png;base64,AAAA' } as HTMLImageElement; return new ImageEntity('b08-frame', image, new Point(0, 0), new Point(10, 5)); } describe('ImageEntity.draw', () => { it('집지 않은 그림은 테두리를 그리지 않는다', () => { const { controller, calls } = countingController(); entity().draw(controller, false, false); expect(calls.lines).toBe(0); expect(calls.images).toBe(1); }); it('집은 그림만 테두리를 보인다', () => { const { controller, calls } = countingController(); entity().draw(controller, false, true); expect(calls.lines).toBe(4); expect(calls.images).toBe(1); }); });