Add a Vitest unit test suite (cart totals, invoice tax grouping, bundle contents)
No test infrastructure existed in this repo yet. Covers the pure logic most likely to silently produce wrong numbers on a live order: discount/ shipping math, per-rate invoice grouping, and bundle-contents string building. Extracted describeBundleContents() out of the checkout route into its own module so it's importable from a test (route.ts files only allow HTTP-method exports).
This commit is contained in:
@@ -316,3 +316,8 @@ export function InvoiceDocument({ order, seller }: { order: InvoiceOrder; seller
|
||||
export async function renderInvoicePdf(order: InvoiceOrder, seller: InvoiceSeller): Promise<Buffer> {
|
||||
return renderToBuffer(<InvoiceDocument order={order} seller={seller} />);
|
||||
}
|
||||
|
||||
// Exported for unit testing (see app/lib/__tests__/invoicePdf.test.ts) —
|
||||
// the actual money math and payment-status logic, independent of PDF
|
||||
// rendering.
|
||||
export const __testables = { isPaidImmediately, groupByTaxRate };
|
||||
|
||||
Reference in New Issue
Block a user