import { describe, it, expect } from 'bun:test'; import { renderTemplate } from '../src/engine/render'; import type { Template } from '../src/types/template'; describe('Template Renderer', () => { it('should render text block', () => { const template: Template = { id: 'test', name: 'Test', width: '80mm', blocks: [ { type: 'text', content: 'Hello World', align: 'center' } ] }; const data = {}; const result = renderTemplate(template, data); expect(result).toBeInstanceOf(Uint8Array); expect(result.length).toBeGreaterThan(0); }); it('should substitute mustache variables', () => { const template: Template = { id: 'test', name: 'Test', width: '80mm', blocks: [ { type: 'text', content: 'Hello {{name}}' } ] }; const data = { name: 'Alice' }; const result = renderTemplate(template, data); const text = new TextDecoder().decode(result); expect(text).toContain('Hello Alice'); }); it('should render divider', () => { const template: Template = { id: 'test', name: 'Test', width: '80mm', blocks: [ { type: 'divider', char: '=' } ] }; const result = renderTemplate(template, {}); const text = new TextDecoder().decode(result); expect(text).toContain('========'); }); });