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
| import { describe, expect, it, vi } from 'vitest';
|
| import { processDetailData, resolveDetailTitle } from './detailData';
|
| vi.mock('@jnpf/utils', () => ({
| getScriptFunc: vi.fn(() => ({ formData }) => {
| formData.dynamicItems = [{ dynamicName: '脚本生成的数据' }];
| return formData;
| }),
| }));
|
| describe('processDetailData', () => {
| it('uses the openDetail title and falls back to the default detail title', () => {
| expect(resolveDetailTitle('自定义详情标题', '详情')).toBe('自定义详情标题');
| expect(resolveDetailTitle('', '详情')).toBe('详情');
| });
|
| it('normalizes virtual child-table keys before processing custom detail data', async () => {
| const table = {
| controlKey: 'dynamicItems',
| __vModel__: '',
| __config__: {
| isVirtualField: true,
| jnpfKey: 'table',
| children: [
| {
| controlKey: 'dynamicName',
| __vModel__: '',
| __config__: { isVirtualField: true, isVirtualFieldInherited: true, isSubTable: true, jnpfKey: 'input' },
| },
| ],
| },
| };
| const formConf = {
| fields: [table],
| funcs: { customDetailData: true, customDetailDataFunc: 'custom detail script' },
| };
|
| const result = await processDetailData(formConf, {}, {});
|
| expect(table.__vModel__).toBe('dynamicItems');
| expect(table.__config__.children[0]?.__vModel__).toBe('dynamicName');
| expect(result.dynamicItems).toEqual([{ dynamicName: '脚本生成的数据' }]);
| });
| });
|
|