From 53df10b74a739dbeb0a99391f43629b8744d472e Mon Sep 17 00:00:00 2001 From: Mike Williamson Date: Tue, 14 Apr 2020 20:31:55 -0400 Subject: [PATCH] Fix lingui plural warning This commit started with fixing a warning about plurals not working when the app was loaded. Fixing that caused some breakage in the tests. Fixing that revealed that none of the funkyness that broke was needed in the first place so I'm ripping that out. The result is everything is much cleaner and there are no warnings to be found anywhere! --- frontend/src/__tests__/App.test.js | 11 +--- frontend/src/__tests__/CreateUserPage.test.js | 13 ++-- .../src/__tests__/DmarcReportPage.test.js | 11 +--- frontend/src/__tests__/EmailField.test.js | 9 +-- frontend/src/__tests__/Footer.test.js | 9 +-- frontend/src/__tests__/LandingPage.test.js | 9 +-- .../__tests__/PasswordConfirmation.test.js | 11 +--- frontend/src/__tests__/PasswordField.test.js | 13 ++-- frontend/src/__tests__/PhaseBanner.test.js | 9 +-- frontend/src/__tests__/QRcodePage.test.js | 9 +-- frontend/src/__tests__/SignInPage.test.js | 13 ++-- frontend/src/__tests__/TopBanner.test.js | 13 +--- .../TwoFactorNotificationBar.test.js | 9 +-- frontend/src/__tests__/TwoFactorPage.test.js | 19 +++--- frontend/src/__tests__/UserCard.test.js | 11 +--- frontend/src/__tests__/UserList.test.js | 17 ++--- frontend/src/__tests__/UserPage.test.js | 9 +-- frontend/src/i18n.config.js | 7 ++- frontend/src/locales/en.js | 2 +- frontend/src/locales/en.po | 62 ++++++++++--------- frontend/src/locales/fr.js | 2 +- frontend/src/locales/fr.po | 61 +++++++++--------- 22 files changed, 125 insertions(+), 204 deletions(-) diff --git a/frontend/src/__tests__/App.test.js b/frontend/src/__tests__/App.test.js index c9eb964fd0..2a7b54505d 100644 --- a/frontend/src/__tests__/App.test.js +++ b/frontend/src/__tests__/App.test.js @@ -7,12 +7,7 @@ import gql from 'graphql-tag' import { UserStateProvider } from '../UserState' import App from '../App' import { I18nProvider } from '@lingui/react' -import { i18n } from '@lingui/core' -import { en } from 'make-plural/plurals' - -i18n.loadLocaleData('en', { plurals: en }) -i18n.load('en', { en: {} }) -i18n.activate('en') +import { setupI18n } from '@lingui/core' const resolvers = { Query: { @@ -69,7 +64,7 @@ describe('', () => { initialState={{ userName: null, jwt: null, tfa: null }} > - + @@ -92,7 +87,7 @@ describe('', () => { initialState={{ userName: null, jwt: null, tfa: null }} > - + ', () => { it('displays an error message', async () => { const { container, queryByText } = render( - + @@ -68,7 +63,7 @@ describe('', () => { it('displays an error message', async () => { const { container, queryByText } = render( - + @@ -97,7 +92,7 @@ describe('', () => { it('displays an error message', async () => { const { container, queryByText } = render( - + diff --git a/frontend/src/__tests__/DmarcReportPage.test.js b/frontend/src/__tests__/DmarcReportPage.test.js index 955706a919..0bc6c79a92 100644 --- a/frontend/src/__tests__/DmarcReportPage.test.js +++ b/frontend/src/__tests__/DmarcReportPage.test.js @@ -6,12 +6,7 @@ import { MockedProvider } from '@apollo/react-testing' import { DmarcReportPage } from '../DmarcReportPage' import { QUERY_DMARC_REPORT } from '../graphql/queries' import { I18nProvider } from '@lingui/react' -import { i18n } from '@lingui/core' -import { en } from 'make-plural/plurals' - -i18n.loadLocaleData('en', { plurals: en }) -i18n.load('en', { en: {} }) -i18n.activate('en') +import { setupI18n } from '@lingui/core' describe('', () => { it('renders pass icons in sub-headers correctly', async () => { @@ -65,7 +60,7 @@ describe('', () => { const { getByRole } = render( - + @@ -137,7 +132,7 @@ describe('', () => { const { getByText, getByRole } = render( - + diff --git a/frontend/src/__tests__/EmailField.test.js b/frontend/src/__tests__/EmailField.test.js index 294ddcd965..23b4bad38f 100644 --- a/frontend/src/__tests__/EmailField.test.js +++ b/frontend/src/__tests__/EmailField.test.js @@ -5,12 +5,7 @@ import { ThemeProvider, theme } from '@chakra-ui/core' import { EmailField } from '../EmailField' import { Formik } from 'formik' import { I18nProvider } from '@lingui/react' -import { i18n } from '@lingui/core' -import { en } from 'make-plural/plurals' - -i18n.loadLocaleData('en', { plurals: en }) -i18n.load('en', { en: {} }) -i18n.activate('en') +import { setupI18n } from '@lingui/core' describe('', () => { describe('when validation fails', () => { @@ -20,7 +15,7 @@ describe('', () => { }) const { getByTestId, getByText } = render( - + ', () => { beforeEach(() => (global.scrollTo = jest.fn())) @@ -16,7 +11,7 @@ describe('