import assert from 'node:assert/strict'; import { test } from 'node:test'; import { buildShortDescription, buildTitle, type CopyFacts } from './copy'; const FACTS: CopyFacts = { lengthIn: 48, widthAvgIn: 18, thicknessIn: 2, bdft: 12 }; test('copy: live-edge leaf title, no dims, figure drops when absent', () => { assert.equal( buildTitle(FACTS, 'Cathedral', 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Cathedral Black Walnut Live Edge Slab', ); assert.equal( buildTitle(FACTS, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Black Walnut Live Edge Slab', ); }); test('copy: dimensional leaf gains "Live Edge" only from the synced edge term (METADATA-5)', () => { assert.equal( buildTitle({ ...FACTS, edgeName: 'Live' }, null, 'Red Oak', { slug: 'dimensional-wood', name: 'Dimensional wood' }), 'Red Oak Live Edge Dimensional', ); assert.equal( buildTitle({ ...FACTS, edgeName: 'Straight' }, null, 'Red Oak', { slug: 'dimensional-wood', name: 'Dimensional wood' }), 'Red Oak Dimensional', ); }); test('copy: knife-blank leaf carries dims', () => { assert.equal( buildTitle(FACTS, null, 'Cherry', { slug: 'knife-blanks', name: 'Knife blanks' }), 'Cherry Knife Blank (48 x 18 x 2 in)', ); }); test('copy: unknown leaf slug falls back to "Slab"', () => { assert.equal( buildTitle(FACTS, 'Spalted', 'Olive', { slug: 'mystery-leaf', name: 'Mystery' }), 'Spalted Olive Slab', ); }); test('copy: title collapses double spaces', () => { assert.equal( buildTitle(FACTS, ' ', 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Black Walnut Live Edge Slab', ); }); test('copy: short description = title + ft/in split + dims + rounded bdft', () => { assert.equal( buildShortDescription(FACTS, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Black Walnut Live Edge Slab, 4ft 0in x 18in x 2in, 12 bdft', ); }); test('copy: short description keeps fractional bdft to 1 dp', () => { assert.equal( buildShortDescription({ ...FACTS, bdft: 11.46 }, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Black Walnut Live Edge Slab, 4ft 0in x 18in x 2in, 11.5 bdft', ); }); test('copy: non-whole feet split into ft + rem inches', () => { assert.equal( buildShortDescription({ ...FACTS, lengthIn: 60 }, null, 'Cherry', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Cherry Live Edge Slab, 5ft 0in x 18in x 2in, 12 bdft', ); assert.equal( buildShortDescription({ ...FACTS, lengthIn: 41.5 }, null, 'Cherry', { slug: 'live-edge-wood', name: 'Live edge wood' }), 'Cherry Live Edge Slab, 3ft 5.5in x 18in x 2in, 12 bdft', ); });