detail-echo.test.mjs
973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
stripValuesFromSchemaRoot,
parseDetailEchoValues
} from '../form-engine/detail-echo.js'
import { createFormEngine } from '../form-engine/core.js'
describe('detail-echo', () => {
it('IT-ECHO-001: stripValuesFromSchemaRoot removes field.value', () => {
const root = {
list: [{ key: 'F1-1', type: 'radio', value: '1', options: [] }]
}
const stripped = stripValuesFromSchemaRoot(root)
assert.equal(stripped.list[0].value, undefined)
})
it('IT-ECHO-002: engine init uses initialValues not schema.value', () => {
const engine = createFormEngine()
const schema = {
list: [
{
key: 'F1-1',
type: 'radio',
options: [
{ label: '在岗', value: 'on' },
{ label: '调休', value: 'off' }
]
}
]
}
const view = engine.init(schema, {
initialValues: { 'F1-1': 'on' }
})
assert.equal(view.values['F1-1'], 'on')
})
})