From cceb4236259cc13bdd35ce8d36d6518f535cef88 Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 5 Aug 2022 15:40:42 +0300 Subject: [PATCH] refactor(TextInput): use ` )} ); diff --git a/src/components/TextInput/__tests__/TextInput.test.tsx b/src/components/TextInput/__tests__/TextInput.test.tsx index cee489e538..302f607daf 100644 --- a/src/components/TextInput/__tests__/TextInput.test.tsx +++ b/src/components/TextInput/__tests__/TextInput.test.tsx @@ -38,13 +38,13 @@ describe('TextInput', () => { test('render clear button with hasClear prop', () => { render(); - expect(screen.getByRole('button')).toBeInTheDocument(); + expect(screen.getByRole('button', {name: 'Clear input value'})).toBeInTheDocument(); }); test('do not render clear button without hasClear prop', () => { render(); - expect(screen.queryByRole('button')).not.toBeInTheDocument(); + expect(screen.queryByRole('button', {name: 'Clear input value'})).not.toBeInTheDocument(); }); test('call onChange when input changes value', () => { @@ -70,7 +70,7 @@ describe('TextInput', () => { const onChangeFn = jest.fn(); const user = userEvent.setup(); render(); - const clear = screen.getByRole('button'); + const clear = screen.getByRole('button', {name: 'Clear input value'}); if (clear) { await user.click(clear); @@ -83,7 +83,7 @@ describe('TextInput', () => { const onUpdateFn = jest.fn(); const user = userEvent.setup(); render(); - const clear = screen.getByRole('button'); + const clear = screen.getByRole('button', {name: 'Clear input value'}); if (clear) { await user.click(clear); diff --git a/src/components/TextInput/i18n/en.json b/src/components/TextInput/i18n/en.json new file mode 100644 index 0000000000..2872f35a98 --- /dev/null +++ b/src/components/TextInput/i18n/en.json @@ -0,0 +1,3 @@ +{ + "label_clear-button": "Clear input value" +} diff --git a/src/components/TextInput/i18n/index.ts b/src/components/TextInput/i18n/index.ts new file mode 100644 index 0000000000..1d6820bcf5 --- /dev/null +++ b/src/components/TextInput/i18n/index.ts @@ -0,0 +1,5 @@ +import {registerKeyset} from '../../utils/registerKeyset'; +import en from './en.json'; +import ru from './ru.json'; + +export default registerKeyset({en, ru}, 'text-input'); diff --git a/src/components/TextInput/i18n/ru.json b/src/components/TextInput/i18n/ru.json new file mode 100644 index 0000000000..ade621014a --- /dev/null +++ b/src/components/TextInput/i18n/ru.json @@ -0,0 +1,3 @@ +{ + "label_clear-button": "Очистить введённое значение" +}