import test from 'node:test'; import assert from 'node:assert/strict'; import { receipt, receiptLine, WIDTH } from '../src/receipt.js'; test('every line is exactly the printer width', () => { for (const line of receipt([{ name: 'Mug', cents: 1200 }]).split('\n')) { assert.equal(line.length, WIDTH); } }); test('prints the receipt the till expects', () => { const printed = receipt([ { name: 'Coffee beans', cents: 1899 }, { name: 'Espresso machine', cents: 124950 }, ]); assert.equal(printed, [ 'Coffee beans..........$18.99', 'Espresso machine....$1249.50', 'TOTAL...............$1268.49', ].join('\n')); }); test('a single line pads the name with dots', () => { assert.equal(receiptLine('Tea', 450), 'Tea....................$4.50'); });