Skip to content
Open
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: 0 additions & 1 deletion src/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
clearIcon = (
<button
type="button"
tabIndex={-1}
onClick={(event) => {
handleReset?.(event);
onClear?.();
Expand Down
40 changes: 16 additions & 24 deletions tests/BaseInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ describe('BaseInput', () => {
const onBlur = jest.fn();
const onFocus = jest.fn();

const user = userEvent.setup();

const Demo: FC = () => {
const [value, setValue] = useState<string>('');

Expand Down Expand Up @@ -97,33 +95,27 @@ describe('BaseInput', () => {
expect(inputEl!.value).toBe('');
});

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

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

// await user.type(inputEl!, 'some text');
// expect(inputEl!.value).toBe('some text');
it.each(['[Space]', '[Enter]'])('By focus and %s', async (key) => {
const user = userEvent.setup();
const { container } = render(<Demo />);

// await user.tab();
// await user.keyboard('[Space]');
// expect(inputEl!.value).toBe('');
// });
const inputEl = container.querySelector('input');
await user.click(inputEl!);

// it('By focus and Enter', async () => {
// const { container } = render(<Demo />);
await user.type(inputEl!, 'some text');
expect(inputEl!.value).toBe('some text');

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

// await user.type(inputEl!, 'some text');
// expect(inputEl!.value).toBe('some text');
const clearIcon = container.querySelector<HTMLButtonElement>(
'.rc-input-clear-icon',
)!;
expect(document.activeElement).toBe(clearIcon);
expect(clearIcon.tabIndex).toBe(0);

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

it('should display clearIcon correctly', () => {
Expand Down
6 changes: 0 additions & 6 deletions tests/__snapshots__/TextArea.allowClear.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`should support allowClear should not show icon if defaultValue is undef
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -33,7 +32,6 @@ exports[`should support allowClear should not show icon if defaultValue is undef
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -54,7 +52,6 @@ exports[`should support allowClear should not show icon if defaultValue is undef
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -75,7 +72,6 @@ exports[`should support allowClear should not show icon if value is undefined, n
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -96,7 +92,6 @@ exports[`should support allowClear should not show icon if value is undefined, n
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand All @@ -117,7 +112,6 @@ exports[`should support allowClear should not show icon if value is undefined, n
>
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-hidden"
tabindex="-1"
type="button"
>
Expand Down
1 change: 0 additions & 1 deletion tests/__snapshots__/TextArea.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exports[`TextArea classNames and styles should work 1`] = `
<button
class="rc-textarea-clear-icon rc-textarea-clear-icon-has-suffix custom-clear"
style="color: orange;"
tabindex="-1"
type="button"
>
Expand Down
7 changes: 0 additions & 7 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ exports[`Input allowClear classNames and styles should work 1`] = `
<button
class="rc-input-clear-icon rc-input-clear-icon-has-suffix custom-clear"
style="color: orange;"
tabindex="-1"
type="button"
>
Expand Down Expand Up @@ -125,7 +124,6 @@ exports[`Input allowClear should change type when click 1`] = `
>
<button
class="rc-input-clear-icon"
tabindex="-1"
type="button"
>
Expand All @@ -150,7 +148,6 @@ 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 @@ -175,7 +172,6 @@ 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 @@ -200,7 +196,6 @@ 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 @@ -225,7 +220,6 @@ 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 @@ -250,7 +244,6 @@ 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