-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBasicInputNumber.test.tsx
More file actions
52 lines (42 loc) · 1.4 KB
/
BasicInputNumber.test.tsx
File metadata and controls
52 lines (42 loc) · 1.4 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
import { renderWithTheme } from '../../testUtil/customRender';
import BasicInputNumber from './BasicInputNumber';
import { BasicInputNumberProps } from './BasicInputNumber.types';
import { act, fireEvent } from '@testing-library/react';
import { getBySelector } from '../../testUtil/customQuery';
describe('lib/BasicInputNumber', () => {
const customRender = (params: BasicInputNumberProps) => {
return renderWithTheme(<BasicInputNumber {...params} />);
};
it('render diff size input number', () => {
const { container } = customRender({
className: 'custom-input-number-class'
});
expect(container).toMatchSnapshot();
const { container: container1 } = customRender({
size: 'large'
});
expect(container1).toMatchSnapshot();
const { container: container2 } = customRender({
size: 'middle'
});
expect(container2).toMatchSnapshot();
const { container: container3 } = customRender({
size: 'small'
});
expect(container3).toMatchSnapshot();
});
it('render integer input', async () => {
const { container } = customRender({
integer: true
});
expect(container).toMatchSnapshot();
const inputElement = getBySelector('input');
fireEvent.change(inputElement, {
target: { value: 1.1111 }
});
await act(async () => {
fireEvent.blur(inputElement);
});
expect(inputElement).toHaveValue('1');
});
});