import assert from 'node:assert/strict' import test from 'node:test' import { buildManualFulfillmentNote, buildManualFulfillmentReference, } from './manual-fulfillment-note.js' test('人工履约编号同时带工单号与平台单号', () => { assert.equal( buildManualFulfillmentReference({ workOrderNo: 'WK26102414033739', platformOrderId: '2628501763808879', orderItemId: 10, }), '工单 WK26102414033739 · 平台单号 2628501763808879', ) }) test('人工履约编号在没有工单号时回退平台单号', () => { assert.equal( buildManualFulfillmentReference({ workOrderNo: null, platformOrderId: '2628501763808879', orderItemId: 10, }), '平台单号 2628501763808879', ) }) test('人工履约编号完全没有单号时回退订单项', () => { assert.equal( buildManualFulfillmentReference({ workOrderNo: null, platformOrderId: '', orderItemId: 10, }), '订单项 #10', ) }) test('人工履约备注包含商品、编号与客服备注并按上限截断', () => { const note = buildManualFulfillmentNote({ skuName: '幸运币2个', reference: '工单 WK26102414033739 · 平台单号 2628501763808879', note: '已发放', maxLength: 300, }) assert.equal( note, '人工履约 幸运币2个 · 工单 WK26102414033739 · 平台单号 2628501763808879 · 已发放', ) assert.equal( buildManualFulfillmentNote({ skuName: '幸运币2个', reference: '工单 WK26102414033739', note: '', maxLength: 12, }), '人工履约 幸运币2个 ·', ) })