You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1006 B
25 lines
1006 B
2 years ago
|
import React, { forwardRef } from 'react';
|
||
3 years ago
|
import InputNumber from '..';
|
||
|
import focusTest from '../../../tests/shared/focusTest';
|
||
2 years ago
|
import { fireEvent, render } from '../../../tests/utils';
|
||
3 years ago
|
|
||
|
describe('prefix', () => {
|
||
|
focusTest(
|
||
2 years ago
|
forwardRef((props, ref) => <InputNumber {...props} prefix="A" ref={ref} />),
|
||
3 years ago
|
{ refFocus: true },
|
||
|
);
|
||
|
it('should support className when has prefix', () => {
|
||
3 years ago
|
const { container } = render(<InputNumber prefix="suffix" className="my-class-name" />);
|
||
2 years ago
|
expect((container.firstChild as HTMLElement)?.className.includes('my-class-name')).toBe(true);
|
||
3 years ago
|
expect(container.querySelector('input')?.className.includes('my-class-name')).toBe(false);
|
||
3 years ago
|
});
|
||
|
|
||
|
it('should trigger focus when prefix is clicked', () => {
|
||
2 years ago
|
const { container } = render(<InputNumber prefix={<i>123</i>} />);
|
||
3 years ago
|
|
||
2 years ago
|
const mockFocus = jest.spyOn(container.querySelector('input')!, 'focus');
|
||
|
fireEvent.mouseUp(container.querySelector('i')!);
|
||
2 years ago
|
expect(mockFocus).toHaveBeenCalled();
|
||
3 years ago
|
});
|
||
|
});
|