41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
|
|
import assert from 'node:assert/strict'
|
|||
|
|
import { readFileSync } from 'node:fs'
|
|||
|
|
import test from 'node:test'
|
|||
|
|
import { fileURLToPath } from 'node:url'
|
|||
|
|
|
|||
|
|
import {
|
|||
|
|
buildStructuredComposerSubmitText
|
|||
|
|
} from '../src/views/scripts/useTravelReimbursementComposerTools.js'
|
|||
|
|
|
|||
|
|
const submitComposerScript = readFileSync(
|
|||
|
|
fileURLToPath(new URL('../src/views/scripts/useTravelReimbursementSubmitComposer.js', import.meta.url)),
|
|||
|
|
'utf8'
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
test('composer formats date-picker expense text into readable structured fields', () => {
|
|||
|
|
const formatted = buildStructuredComposerSubmitText(
|
|||
|
|
'发生时间:2026-05-20 至 2026-05-23,去上海支撑上海国电的服务器部署,出差3天',
|
|||
|
|
{
|
|||
|
|
mode: 'range',
|
|||
|
|
start_date: '2026-05-20',
|
|||
|
|
end_date: '2026-05-23',
|
|||
|
|
business_time: '2026-05-20 至 2026-05-23'
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
assert.equal(
|
|||
|
|
formatted,
|
|||
|
|
[
|
|||
|
|
'发生时间:2026-05-20 至 2026-05-23',
|
|||
|
|
'地点:上海',
|
|||
|
|
'事由:支撑上海国电的服务器部署',
|
|||
|
|
'天数:3天'
|
|||
|
|
].join('\n')
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
test('composer keeps backend raw text but displays structured user message', () => {
|
|||
|
|
assert.match(submitComposerScript, /const rawText = resolveComposerSubmitText\(options\.rawText\)\.trim\(\)/)
|
|||
|
|
assert.match(submitComposerScript, /resolveComposerDisplaySubmitText\(rawText\)/)
|
|||
|
|
})
|