diff --git a/src/components/Form/test.js b/src/components/Form/test.js index 4a142ce..4e4b6fe 100644 --- a/src/components/Form/test.js +++ b/src/components/Form/test.js @@ -42,8 +42,13 @@ describe('Form', () => { const component = shallow(
); + + const exprInput = component.find('[name="expr"]'); + const syntaxInput = component.find('[name="syntax"]'); + exprInput.simulate('change', { target: { name: 'expr', value: 'Test expression' } }); + syntaxInput.simulate('change', { target: { name: 'syntax', value: 'test' } }); + const eventObj = { preventDefault: jest.fn() }; - component.setState({ syntax: 'test', expr: 'Test expression' }); component.find('form').simulate('submit', eventObj); expect(eventObj.preventDefault).toHaveBeenCalled(); diff --git a/src/components/LocaleSwitcher/__snapshots__/test.js.snap b/src/components/LocaleSwitcher/__snapshots__/test.js.snap index 3b4a583..795b464 100644 --- a/src/components/LocaleSwitcher/__snapshots__/test.js.snap +++ b/src/components/LocaleSwitcher/__snapshots__/test.js.snap @@ -11,7 +11,20 @@ exports[`LocaleSwitcher rendering 1`] = ` diff --git a/src/components/LocaleSwitcher/index.js b/src/components/LocaleSwitcher/index.js index 6c8acbc..c7c5114 100644 --- a/src/components/LocaleSwitcher/index.js +++ b/src/components/LocaleSwitcher/index.js @@ -26,8 +26,6 @@ class LocaleSwitcher extends React.PureComponent { current: localeToAvailable(i18n.language || '', Object.keys(locales), 'en') } - localeSelector = React.createRef() - componentDidMount() { i18n.on('languageChanged', this.handleLanguageChange); } @@ -36,8 +34,8 @@ class LocaleSwitcher extends React.PureComponent { i18n.off('languageChanged', this.handleLanguageChange); } - handleSelectChange = () => { - i18n.changeLanguage(this.localeSelector.current.value); + handleSelectChange = ({ target }) => { + i18n.changeLanguage(target.value); } handleLanguageChange = lang => { @@ -50,7 +48,7 @@ class LocaleSwitcher extends React.PureComponent { return