字段 kind 与只读格式对齐产品:自由文本接种量、冻存仅 YYYY-MM-DD。 Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { describe, it } from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import {
|
||
resolveProductionReceptionFields,
|
||
formatProductionFieldValue,
|
||
type ProductionReceptionRecord
|
||
} from './sample-production-reception-fields'
|
||
|
||
describe('inoculationAmount / cryopreservationTime field kinds', () => {
|
||
it('marks inoculationAmount as text and cryopreservationTime as date for UC-MSC profiles', () => {
|
||
for (const source of ['cell_storage', 'research_donation'] as const) {
|
||
const fields = resolveProductionReceptionFields(source, '脐带间充质干细胞')
|
||
const inoc = fields.find((f) => f.key === 'inoculationAmount')
|
||
const cryo = fields.find((f) => f.key === 'cryopreservationTime')
|
||
assert.ok(inoc)
|
||
assert.equal(inoc.kind, 'text')
|
||
assert.equal(inoc.maxLength, 255)
|
||
assert.ok(cryo)
|
||
assert.equal(cryo.kind, 'date')
|
||
}
|
||
})
|
||
|
||
it('formats free-text inoculation and date-only cryopreservation', () => {
|
||
const fields = resolveProductionReceptionFields('cell_storage', '脐带间充质干细胞')
|
||
const inoc = fields.find((f) => f.key === 'inoculationAmount')!
|
||
const cryo = fields.find((f) => f.key === 'cryopreservationTime')!
|
||
const record: ProductionReceptionRecord = {
|
||
inoculationAmount: '约 5×10⁶ cells,接种体积 2ml',
|
||
cryopreservationTime: '2026-07-14 15:30:00'
|
||
}
|
||
assert.equal(formatProductionFieldValue(inoc, record), '约 5×10⁶ cells,接种体积 2ml')
|
||
assert.equal(formatProductionFieldValue(cryo, record), '2026-07-14')
|
||
})
|
||
})
|