store-template-schema.test.mjs
1.62 KB
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
39
40
41
42
43
44
45
46
47
48
49
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { loadSchemaFixture } from './schemaFixture.mjs'
const storeSchema = loadSchemaFixture('store')
function findFieldByKey(list, key) {
return list.find(item => item.key === key)
}
describe('store template schema fixture', () => {
it('IT-STORE-TPL-001: F2-1 completeFun targets F2-2 staff count', () => {
const f21 = findFieldByKey(storeSchema.list, 'F2-1')
assert.equal(f21?.type, 'multipleSelect')
assert.equal(f21?.optionsKey, 'storeStaffList')
assert.deepEqual(f21?.completeFun, {
key: 'F2-2',
result: '(list.length)'
})
})
it('IT-STORE-TPL-002: F2-2 has disabledFun keyed on F2-1', () => {
const f22 = findFieldByKey(storeSchema.list, 'F2-2')
assert.equal(f22?.type, 'numberInput')
assert.equal(f22?.value, 0)
assert.deepEqual(f22?.disabledFun, {
keys: ['F2-1'],
result: 'val1 != null'
})
})
it('IT-STORE-TPL-003: F2-91 isYB divider includes ybCode and qyCode', () => {
const divider = findFieldByKey(storeSchema.list, 'F2-91')
assert.equal(divider?.type, 'divider')
assert.equal(divider?.isYB, true)
assert.deepEqual(divider?.ybCode, [110201, 110202])
assert.deepEqual(divider?.qyCode, [110101, 110102])
})
it('IT-STORE-TPL-004: F2-11 other-brand subform has filterBrandId', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-11')
assert.equal(subform?.type, 'subform')
assert.deepEqual(subform?.filterBrandId, [
3454, 3503, 3458, 3574, 3502, 3067
])
const orderChild = subform?.children?.[0]?.find(item => item.key === 'F2-11-1')
assert.equal(orderChild?.optionsKey, '4sStaffList')
})
})