Skip to content

Commit

Permalink
chore: wrapper also has oor cls (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 27, 2023
1 parent f667c38 commit 7595a5f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
}
};

// ====================== Input =======================
const outOfRangeCls = isOutOfRange && `${prefixCls}-out-of-range`;

const getInputElement = () => {
// Fix https://fb.me/react-unknown-prop
const otherProps = omit(
Expand Down Expand Up @@ -186,7 +189,6 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
prefixCls,
{
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-out-of-range`]: isOutOfRange,
},
classNames?.input,
)}
Expand Down Expand Up @@ -246,7 +248,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
<BaseInput
{...rest}
prefixCls={prefixCls}
className={className}
className={clsx(className, outOfRangeCls)}
inputElement={getInputElement()}
handleReset={handleReset}
value={formatValue}
Expand Down
29 changes: 29 additions & 0 deletions tests/count.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,33 @@ describe('Input.Count', () => {
expect(container.querySelector('input')?.value).toEqual('🔥');
expect(onCompositionEnd).toHaveBeenCalled();
});

describe('cls', () => {
it('raw', () => {
const { container } = render(
<Input
count={{
max: 3,
}}
defaultValue="bamboo"
/>,
);

expect(container.querySelector('.rc-input-out-of-range')).toBeTruthy();
});

it('wrapper', () => {
const { container } = render(
<Input
count={{
max: 3,
show: true,
}}
defaultValue="bamboo"
/>,
);

expect(container.querySelector('.rc-input-out-of-range')).toBeTruthy();
});
});
});

0 comments on commit 7595a5f

Please sign in to comment.