fix lint; add test case

This commit is contained in:
DisLido 2024-11-15 17:04:33 +08:00
parent 83b2cfe380
commit fc93f1fc6e
2 changed files with 39 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { CloseOutlined } from '@ant-design/icons';
import type { SelectProps } from '..';
import Select from '..';
import Form from '../../form';
import { resetWarned } from '../../_util/warning';
import focusTest from '../../../tests/shared/focusTest';
import mountTest from '../../../tests/shared/mountTest';
@ -126,6 +127,43 @@ describe('Select', () => {
});
});
describe('clear icon position', () => {
it('normal', () => {
const { container } = render(
<Select allowClear options={[{ value: '1', label: '1' }]} value="1" />,
);
expect(
getComputedStyle(container.querySelector('.ant-select-clear')!).insetInlineEnd,
).toEqual('11px');
});
it('hasFeedback, has validateStatus', () => {
const { container } = render(
<Form>
<Form.Item hasFeedback validateStatus="error">
<Select allowClear options={[{ value: '1', label: '1' }]} value="1" />,
</Form.Item>
</Form>,
);
expect(
getComputedStyle(container.querySelector('.ant-select-clear')!).insetInlineEnd,
).toEqual('33px');
});
it('hasFeedback, no validateStatus', () => {
const { container } = render(
<Form>
<Form.Item hasFeedback validateStatus="">
<Select allowClear options={[{ value: '1', label: '1' }]} value="1" />,
</Form.Item>
</Form>,
);
expect(
getComputedStyle(container.querySelector('.ant-select-clear')!).insetInlineEnd,
).toEqual('11px');
});
});
describe('Deprecated', () => {
it('should ignore mode="combobox"', () => {
const { asFragment } = render(

View File

@ -186,7 +186,7 @@ const genBaseStyle: GenerateStyle<SelectToken> = (token) => {
// ========================= Feedback ==========================
[`${componentCls}-status`]: {
[`&-error, &-warning, &-success, &-validating`]: {
'&-error, &-warning, &-success, &-validating': {
[`&${componentCls}-has-feedback`]: {
[`${componentCls}-clear`]: {
insetInlineEnd: token