Skip to content

Commit

Permalink
Merge pull request #5950 from mozilla/nz
Browse files Browse the repository at this point in the history
test(l10n): follow-up test for #5948 (currency l10n)
  • Loading branch information
dannycoates committed Jul 21, 2020
2 parents 8c97d25 + e87996b commit 8c117b5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/fxa-payments-server/package.json
Expand Up @@ -79,6 +79,7 @@
"express-http-proxy": "^1.6.0",
"fetch-mock": "^8.1.0",
"handlebars": "^4.5.3",
"intl": "1.2.5",
"intl-pluralrules": "^1.1.1",
"jest": "^24.9.0",
"nock": "^12.0.3",
Expand Down
Expand Up @@ -4,6 +4,9 @@

/* eslint jest/valid-expect: 0 */

import IntlPolyfill from 'intl';
Intl.NumberFormat = IntlPolyfill.NumberFormat;

import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
Expand All @@ -14,9 +17,10 @@ import sinon from 'sinon';

import fetchMock from 'fetch-mock';
import AppLocalizationProvider from './AppLocalizationProvider';
import { getLocalizedCurrency } from './formats';

describe('<AppLocalizationProvider/>', () => {
const locales = ['en-US', 'es-ES'];
const locales = ['en-GB', 'en-US', 'es-ES'];
const bundles = ['greetings', 'farewells'];
function waitUntilTranslated() {
return waitUntil(
Expand All @@ -28,6 +32,7 @@ describe('<AppLocalizationProvider/>', () => {
fetchMock.get('/locales/en-US/greetings.ftl', 'hello = Hello\n');
fetchMock.get('/locales/en-US/farewells.ftl', 'goodbye = Goodbye\n');
fetchMock.get('/locales/es-ES/greetings.ftl', 'hello = Hola\n');
fetchMock.get('/locales/en-GB/greetings.ftl', 'hello = Hello { $amount }')
fetchMock.get('*', { throws: new Error() });
});

Expand Down Expand Up @@ -119,4 +124,19 @@ describe('<AppLocalizationProvider/>', () => {

return expect(Promise.reject(err)).rejects.toHaveProperty('code', 404);
});

it('translate to en-NZ currency', async () => {
const { getByTestId } = render(
<AppLocalizationProvider bundles={bundles} userLocales={['en-NZ']}>
<main data-testid="result">
<Localized id="hello" $amount={getLocalizedCurrency(123, 'USD')}>
<div>untranslated</div>
</Localized>
</main>
</AppLocalizationProvider>
);
await waitUntilTranslated();

expect(getByTestId('result')).toHaveTextContent('Hello ⁨US$1.23');
});
});
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -15943,6 +15943,7 @@ fsevents@^1.2.7:
handlebars: ^4.5.3
helmet: ^3.23.3
hot-shots: ^7.6.0
intl: 1.2.5
intl-pluralrules: ^1.1.1
jest: ^24.9.0
joi: ^14.3.1
Expand Down

0 comments on commit 8c117b5

Please sign in to comment.