Skip to content

Commit

Permalink
test(Input): add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
shervinchen committed May 3, 2024
1 parent a3ae798 commit 4f14eee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/Input/InputElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ const InputLeftElement: FC<Omit<InputElementProps, 'placement'>> = ({
}) => {
const classes = classNames('raw-input-left-element', className);

return <InputElement className={classes} placement="left" {...resetProps} />;
return (
<InputElement
data-testid="inputLeftElement"
className={classes}
placement="left"
{...resetProps}
/>
);
};

const InputRightElement: FC<Omit<InputElementProps, 'placement'>> = ({
Expand All @@ -65,7 +72,14 @@ const InputRightElement: FC<Omit<InputElementProps, 'placement'>> = ({
}) => {
const classes = classNames('raw-input-right-element', className);

return <InputElement className={classes} placement="right" {...resetProps} />;
return (
<InputElement
data-testid="inputRightElement"
className={classes}
placement="right"
{...resetProps}
/>
);
};

export { InputLeftElement, InputRightElement };
13 changes: 13 additions & 0 deletions packages/Input/__tests__/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ describe('Input', () => {
expect(screen.getByText('.0')).toBeInTheDocument();
});

test('should inside element support clickable style', () => {
render(
<Input.Group>
<Input.LeftElement clickable>$</Input.LeftElement>
<Input placeholder="Enter amount" />
<Input.RightElement>.0</Input.RightElement>
</Input.Group>
);
const leftElement = screen.getByTestId('inputLeftElement');
expect(getComputedStyle(leftElement).pointerEvents).toBe('auto');
expect(getComputedStyle(leftElement).cursor).toBe('pointer');
});

test('should support addon element', () => {
render(
<Input.Group>
Expand Down

0 comments on commit 4f14eee

Please sign in to comment.