Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
clearIcon = (
<button
type="button"
tabIndex={-1}
onClick={(event) => {
handleReset?.(event);
onClear?.();
Expand Down
40 changes: 20 additions & 20 deletions tests/BaseInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,33 @@ describe('BaseInput', () => {
expect(inputEl!.value).toBe('');
});

it('By focus and Space', async () => {
const { container } = render(<Demo />);
// it('By focus and Space', async () => {
// const { container } = render(<Demo />);

const inputEl = container.querySelector('input');
await user.click(inputEl!);
// const inputEl = container.querySelector('input');
// await user.click(inputEl!);

await user.type(inputEl!, 'some text');
expect(inputEl!.value).toBe('some text');
// await user.type(inputEl!, 'some text');
// expect(inputEl!.value).toBe('some text');

await user.tab();
await user.keyboard('[Space]');
expect(inputEl!.value).toBe('');
});
// await user.tab();
// await user.keyboard('[Space]');
// expect(inputEl!.value).toBe('');
// });

it('By focus and Enter', async () => {
const { container } = render(<Demo />);
// it('By focus and Enter', async () => {
// const { container } = render(<Demo />);

const inputEl = container.querySelector('input');
await user.click(inputEl!);
// const inputEl = container.querySelector('input');
// await user.click(inputEl!);

await user.type(inputEl!, 'some text');
expect(inputEl!.value).toBe('some text');
// await user.type(inputEl!, 'some text');
// expect(inputEl!.value).toBe('some text');

await user.tab();
await user.keyboard('[Enter]');
expect(inputEl!.value).toBe('');
});
// await user.tab();
// await user.keyboard('[Enter]');
// expect(inputEl!.value).toBe('');
// });
});

it('should display clearIcon correctly', () => {
Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ exports[`Input allowClear should change type when click 1`] = `
>
<button
class="rc-input-clear-icon"
tabindex="-1"
type="button"
>
Expand All @@ -141,6 +142,7 @@ exports[`Input allowClear should change type when click 2`] = `
>
<button
class="rc-input-clear-icon rc-input-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -165,6 +167,7 @@ exports[`Input allowClear should not show icon if defaultValue is undefined or e
>
<button
class="rc-input-clear-icon rc-input-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -189,6 +192,7 @@ exports[`Input allowClear should not show icon if defaultValue is undefined or e
>
<button
class="rc-input-clear-icon rc-input-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -213,6 +217,7 @@ exports[`Input allowClear should not show icon if value is undefined or empty st
>
<button
class="rc-input-clear-icon rc-input-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -237,6 +242,7 @@ exports[`Input allowClear should not show icon if value is undefined or empty st
>
<button
class="rc-input-clear-icon rc-input-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand Down