ant-design/components/input-number/__tests__/prefix.test.js
黑雨 8c34cb793f
feat: Replace input-number part test with testing lib (#36080)
* feat: Replace input-number part test with testing lib

* feat: update rc-input-number version
2022-07-20 20:47:09 +08:00

25 lines
981 B
JavaScript

import React, { forwardRef } from 'react';
import InputNumber from '..';
import focusTest from '../../../tests/shared/focusTest';
import { fireEvent, render } from '../../../tests/utils';
describe('prefix', () => {
focusTest(
forwardRef((props, ref) => <InputNumber {...props} prefix="A" ref={ref} />),
{ refFocus: true },
);
it('should support className when has prefix', () => {
const { container } = render(<InputNumber prefix="suffix" className="my-class-name" />);
expect(container.firstChild?.className.includes('my-class-name')).toBe(true);
expect(container.querySelector('input')?.className.includes('my-class-name')).toBe(false);
});
it('should trigger focus when prefix is clicked', () => {
const { container } = render(<InputNumber prefix={<i>123</i>} />);
const mockFocus = jest.spyOn(container.querySelector('input'), 'focus');
fireEvent.mouseUp(container.querySelector('i'));
expect(mockFocus).toBeCalled();
});
});