import { InvoiceDocumentModel, InvoiceDocumentService } from "./invoice-document.service"; const model = (over: Partial = {}): InvoiceDocumentModel => ({ kind: "INVOICE", title: "Freight", documentNumber: "INV-20260812-00001", issuedAt: new Date(2026, 7, 12), status: "PENDING", currency: "ETB", summary: [{ label: "Status", value: "PENDING" }], lines: [], totals: [{ label: "Total", amount: 100, grand: true }], ...over, }); describe("InvoiceDocumentService.buildHtml — EIMS QR", () => { const service = new InvoiceDocumentService({} as never, {} as never, {} as never); it("renders no QR block when qrImageUrl is unset", () => { const html = service.buildHtml(model()); expect(html).not.toContain('class="qr"'); }); it("renders the QR image when qrImageUrl is set", () => { const html = service.buildHtml(model({ qrImageUrl: "data:image/png;base64,QR" })); expect(html).toContain('class="qr"'); expect(html).toContain('src="data:image/png;base64,QR"'); }); it("still shows the IRN text row via the ordinary summary grid", () => { const html = service.buildHtml( model({ summary: [{ label: "EIMS IRN", value: "IRN-123" }] }), ); expect(html).toContain("EIMS IRN"); expect(html).toContain("IRN-123"); }); it("widens the summary's right margin only when a QR is present, to clear the QR block", () => { // "summary-with-qr" also appears in the always-present