Skip to content

Commit 5735f23

Browse files
committed
Add tests related to issues/187 to confirm fixed
1 parent cab1ed3 commit 5735f23

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

client/src/components/__tests__/DynamicJsonForm.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,40 @@ import { describe, it, expect, jest } from '@jest/globals';
33
import DynamicJsonForm from '../DynamicJsonForm';
44
import type { JsonSchemaType } from '../DynamicJsonForm';
55

6+
describe('DynamicJsonForm String Fields', () => {
7+
const renderForm = (props = {}) => {
8+
const defaultProps = {
9+
schema: {
10+
type: "string" as const,
11+
description: "Test string field"
12+
} satisfies JsonSchemaType,
13+
value: undefined,
14+
onChange: jest.fn()
15+
};
16+
return render(<DynamicJsonForm {...defaultProps} {...props} />);
17+
};
18+
19+
describe('Type Validation', () => {
20+
it('should handle numeric input as string type', () => {
21+
const onChange = jest.fn();
22+
renderForm({ onChange });
23+
24+
const input = screen.getByRole('textbox');
25+
fireEvent.change(input, { target: { value: '123321' } });
26+
27+
expect(onChange).toHaveBeenCalledWith('123321');
28+
// Verify the value is a string, not a number
29+
expect(typeof onChange.mock.calls[0][0]).toBe('string');
30+
});
31+
32+
it('should render as text input, not number input', () => {
33+
renderForm();
34+
const input = screen.getByRole('textbox');
35+
expect(input).toHaveProperty('type', 'text');
36+
});
37+
});
38+
});
39+
640
describe('DynamicJsonForm Integer Fields', () => {
741
const renderForm = (props = {}) => {
842
const defaultProps = {

0 commit comments

Comments
 (0)