mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 20:40:55 +00:00
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { ContractRendererService } from './contract-renderer.service';
|
|
import { getTemplateMeta } from './contract-template.registry';
|
|
import type { ContractViewModel } from './contract-view-model.builder';
|
|
|
|
describe('ContractRendererService', () => {
|
|
const renderer = new ContractRendererService();
|
|
renderer.onModuleInit();
|
|
|
|
function minimalView(templateKey: string): ContractViewModel {
|
|
const template = getTemplateMeta(templateKey);
|
|
return {
|
|
bookingId: 'test-id',
|
|
reference: 'BK-TEST-001',
|
|
status: 'CONTRACT_READY',
|
|
templateKey,
|
|
template,
|
|
contractDate: '1 January 2026',
|
|
contractYear: 2026,
|
|
client: {
|
|
companyName: 'Test Co',
|
|
companyAddress: 'Addis Ababa',
|
|
companyLocation: 'Ethiopia',
|
|
phone: '+251900000000',
|
|
email: 'test@example.com',
|
|
tinNumber: '1234567890',
|
|
},
|
|
pricing: {
|
|
lineItems: [{ label: 'RAIL', description: 'Rail transport', amount: 1000, currency: 'ETB' }],
|
|
surcharges: [],
|
|
totalAmount: 1000,
|
|
currency: 'ETB',
|
|
originLabel: 'SGTD',
|
|
destinationLabel: 'Modjo',
|
|
containerLines: [{ label: '40ft', quantity: 2, vgmPerUnitTons: 12 }],
|
|
},
|
|
signatures: [],
|
|
canSignCustomer: true,
|
|
canSignStaff: false,
|
|
hasContractDocument: false,
|
|
hasCustomerSignature: false,
|
|
hasStaffSignature: false,
|
|
};
|
|
}
|
|
|
|
it('renders import flagship with Nagad and Article 5', () => {
|
|
const html = renderer.render(minimalView('IMP_CON_ETB_TRANSPORT_ONLY'));
|
|
expect(html).toContain('Djibouti Nagad');
|
|
expect(html).toContain('Article 5: Contract Price');
|
|
expect(html).toContain('Article 2: Obligations of the Client');
|
|
});
|
|
|
|
it('renders export variant without import empty-return clause', () => {
|
|
const html = renderer.render(minimalView('EXP_CON_USD_TRANSPORT_ONLY'));
|
|
expect(html).toContain('export corridors');
|
|
expect(html).not.toContain('Return empty containers from Dire Dawa');
|
|
});
|
|
});
|