优化
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { run, values } from './finance-settlement-full.mjs'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { receiptBody, run, values } from './finance-settlement-full.mjs'
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url))
|
||||
const source = fs.readFileSync(path.join(here, 'finance-settlement-full.mjs'), 'utf8')
|
||||
const response = (data, http = 200, code = '200') => ({ http, body: { code, data } })
|
||||
|
||||
function fakeContext(overrides = {}) {
|
||||
@@ -63,6 +68,16 @@ test('values helper supports nested arrays while run consumes frozen top-level a
|
||||
assert.deepEqual(values({ marker: 'x', selected: { id: 3 } }), [{ id: 3 }])
|
||||
})
|
||||
|
||||
test('receipt body preserves 19-digit customer and voucher IDs through JSON', () => {
|
||||
const body = receiptBody({ marker: 'RUN-1' }, '2088073097986560001',
|
||||
'2088073285653299201', [{ billId: 13, amount: 1 }])
|
||||
const roundTrip = JSON.parse(JSON.stringify(body))
|
||||
assert.equal(roundTrip.customerId, '2088073097986560001')
|
||||
assert.deepEqual(roundTrip.voucherFileIds, ['2088073285653299201'])
|
||||
assert.match(source, /customerId: String\(customerId\)/)
|
||||
assert.doesNotMatch(source, /customerId: Number\(customerId\)/)
|
||||
})
|
||||
|
||||
test('run 使用 receipts 完成应收部分、全额及多单分配,使用 transactions 完成 AP', async () => {
|
||||
const context = fakeContext()
|
||||
await run(context)
|
||||
|
||||
Reference in New Issue
Block a user