diff --git a/client/i18n-test.js b/client/i18n-test.js new file mode 100644 index 00000000..fcef18a7 --- /dev/null +++ b/client/i18n-test.js @@ -0,0 +1,26 @@ +import i18n from 'i18next'; +import { initReactI18next } from 'react-i18next'; + +import translations from '../translations/locales/en-US/translations.json'; + +i18n + .use(initReactI18next) + .init({ + lng: 'en-US', + fallbackLng: 'en-US', + + // have a common namespace used around the full app + ns: ['translations'], + defaultNS: 'translations', + + debug: false, + + interpolation: { + escapeValue: false, // not needed for react!! + }, + + resources: { 'en-US': { translations } }, + }); + + +export default i18n; diff --git a/client/jest.setup.js b/client/jest.setup.js index 233c76db..79652c74 100644 --- a/client/jest.setup.js +++ b/client/jest.setup.js @@ -3,21 +3,3 @@ import '@babel/polyfill'; // See: https://github.com/testing-library/jest-dom // eslint-disable-next-line import/no-extraneous-dependencies import '@testing-library/jest-dom'; - -import lodash from 'lodash'; - -// For testing, we use en-US and provide a mock implementation -// of t() that finds the correct translation -import translations from '../translations/locales/en-US/translations.json'; - -// This function name needs to be prefixed with "mock" so that Jest doesn't -// complain that it's out-of-scope in the mock below -const mockTranslate = key => lodash.get(translations, key); - -jest.mock('react-i18next', () => ({ - // this mock makes sure any components using the translate HoC receive the t function as a prop - withTranslation: () => (Component) => { - Component.defaultProps = { ...Component.defaultProps, t: mockTranslate }; - return Component; - }, -})); diff --git a/client/modules/IDE/components/FileNode.jsx b/client/modules/IDE/components/FileNode.jsx index 0533091a..f4b8166d 100644 --- a/client/modules/IDE/components/FileNode.jsx +++ b/client/modules/IDE/components/FileNode.jsx @@ -67,7 +67,7 @@ FileName.propTypes = { name: PropTypes.string.isRequired }; -export class FileNode extends React.Component { +class FileNode extends React.Component { constructor(props) { super(props); @@ -419,4 +419,7 @@ const TranslatedFileNode = withTranslation()(FileNode); const ConnectedFileNode = connect(mapStateToProps, mapDispatchToProps)(TranslatedFileNode); -export default ConnectedFileNode; +export { + TranslatedFileNode as FileNode, + ConnectedFileNode as default +}; diff --git a/client/modules/IDE/components/FileNode.test.jsx b/client/modules/IDE/components/FileNode.test.jsx index ddb8fec7..84b14aa5 100644 --- a/client/modules/IDE/components/FileNode.test.jsx +++ b/client/modules/IDE/components/FileNode.test.jsx @@ -1,5 +1,6 @@ import React from 'react'; -import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'; + +import { fireEvent, render, screen, waitFor, within } from '../../../test-utils'; import { FileNode } from './FileNode'; describe('', () => { diff --git a/client/modules/IDE/components/Toolbar.jsx b/client/modules/IDE/components/Toolbar.jsx index 5a126b35..5da38560 100644 --- a/client/modules/IDE/components/Toolbar.jsx +++ b/client/modules/IDE/components/Toolbar.jsx @@ -86,7 +86,7 @@ class Toolbar extends React.Component { this.props.setTextOutput(true); this.props.setGridOutput(true); }} - aria-label="Play sketch" + aria-label={this.props.t('Toolbar.PlaySketchARIA')} disabled={this.props.infiniteLoop} >