-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathform.test.tsx
More file actions
76 lines (67 loc) · 2.36 KB
/
form.test.tsx
File metadata and controls
76 lines (67 loc) · 2.36 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { describe, expect, it } from 'vitest';
import { PdfForm } from './form';
import type { PdfFormGroup } from './form.types';
describe('PdfForm', () => {
const variants = ['underline', 'box', 'outlined', 'ghost'] as const;
const layouts = ['single', 'two-column', 'three-column'] as const;
const baseGroup: PdfFormGroup = {
title: 'Contact',
fields: [
{ label: 'Name' },
{ label: 'Email', hint: '[email protected]' },
{ label: 'Phone', height: 24 },
],
};
it('renders with empty groups array', () => {
expect(() => PdfForm({ groups: [] })).not.toThrow();
});
it('renders all variants', () => {
for (const variant of variants) {
expect(() => PdfForm({ groups: [baseGroup], variant })).not.toThrow();
}
});
it('renders all column layouts', () => {
for (const layout of layouts) {
expect(() => PdfForm({ groups: [{ ...baseGroup, layout }] })).not.toThrow();
}
});
it('renders both labelPositions', () => {
for (const labelPosition of ['above', 'left'] as const) {
expect(() => PdfForm({ groups: [baseGroup], labelPosition })).not.toThrow();
}
});
it('renders with title/subtitle (adds form divider)', () => {
// form.tsx:108 — title or subtitle triggers the formDivider row.
expect(() =>
PdfForm({ title: 'Application', subtitle: 'Fill every field', groups: [baseGroup] })
).not.toThrow();
expect(() => PdfForm({ title: 'Application', groups: [baseGroup] })).not.toThrow();
expect(() => PdfForm({ subtitle: 'Only', groups: [baseGroup] })).not.toThrow();
});
it('renders groups with no title, empty fields, and uneven column chunks', () => {
expect(() => PdfForm({ groups: [{ fields: [] }] })).not.toThrow();
expect(() =>
PdfForm({
groups: [
{ fields: [{ label: 'A' }], layout: 'three-column' },
{ fields: [{ label: 'A' }, { label: 'B' }], layout: 'three-column' },
{
fields: [
{ label: 'A' },
{ label: 'B' },
{ label: 'C' },
{ label: 'D' },
{ label: 'E' },
],
layout: 'two-column',
},
],
})
).not.toThrow();
});
it('accepts noWrap and a style override', () => {
expect(() =>
PdfForm({ groups: [baseGroup], noWrap: true, style: { padding: 12 } })
).not.toThrow();
});
});