1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| import { describe, expect, it } from 'vitest';
|
| import { buildDraftFields } from '../../src/domain/draft';
|
| const field = (tag: string, type: any, currentValue: boolean | string) => ({ alias: tag, currentValue, internalId: `id-${tag}`, options: [], tag, type });
|
| describe('buildDraftFields', () => {
| it('fills only empty standard fields and always applies checkbox data', () => {
| const fields = buildDraftFields([
| field('eln.field.empty', 'text', ''), field('eln.field.kept', 'text', 'document'), field('eln.field.ok', 'checkbox', true),
| ], { fields: {
| 'eln.field.empty': { type: 'text', value: 'api' },
| 'eln.field.kept': { type: 'text', value: 'api' },
| 'eln.field.ok': { type: 'checkbox', value: false },
| } });
| expect(fields.map((item) => item.draftValue)).toEqual(['api', 'document', false]);
| });
|
| it('keeps document fields when API fields are empty', () => {
| expect(buildDraftFields([field('eln.field.name', 'text', 'A')], { fields: {} })).toHaveLength(1);
| });
| });
|
|