Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vsumner committed Jun 6, 2024
1 parent ab4dfb9 commit 2fc9074
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
42 changes: 18 additions & 24 deletions packages/react-i18n/src/utilities/tests/translate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
translate,
} from '../translate';

const isModernNode = process.version.startsWith('v18.');

describe('memoizedNumberFormatter()', () => {
it.each`
locale | expectedValue | expectedLocale
Expand All @@ -33,17 +31,16 @@ describe('memoizedNumberFormatter()', () => {
},
);

/* eslint-disable jest/no-if */
it.each`
locale | expectedValue | expectedLocale
${'en-US'} | ${'$1.23'} | ${'en-US-u-nu-latn'}
${'fr-CA'} | ${'1,23 $ US'} | ${'fr-CA-u-nu-latn'}
${'zh-Hans-hk'} | ${'US$1.23'} | ${'zh-Hans-HK-u-nu-latn'}
${'ar-EG'} | ${isModernNode ? '\u200F1.23 US$' : 'US$ 1.23'} | ${'ar-EG-u-nu-latn'}
${'ar-EG-u-nu-arab'} | ${isModernNode ? '\u200F1.23 US$' : 'US$ 1.23'} | ${'ar-EG-u-nu-latn'}
${'fa-IR'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-u-nu-arabext-x-ab-cdefg'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-x-ab-cdefg-u-nu-arabext'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
locale | expectedValue | expectedLocale
${'en-US'} | ${'$1.23'} | ${'en-US-u-nu-latn'}
${'fr-CA'} | ${'1,23 $ US'} | ${'fr-CA-u-nu-latn'}
${'zh-Hans-hk'} | ${'US$1.23'} | ${'zh-Hans-HK-u-nu-latn'}
${'ar-EG'} | ${'\u200F1.23 US$'} | ${'ar-EG-u-nu-latn'}
${'ar-EG-u-nu-arab'} | ${'\u200F1.23 US$'} | ${'ar-EG-u-nu-latn'}
${'fa-IR'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-u-nu-arabext-x-ab-cdefg'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-x-ab-cdefg-u-nu-arabext'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
`(
'returns formatted currency in the $locale locale with the latin numbering system',
({locale, expectedValue, expectedLocale}) => {
Expand All @@ -58,7 +55,6 @@ describe('memoizedNumberFormatter()', () => {
);
},
);
/* eslint-enable jest/no-if */

describe('when Intl.Locale throws an error', () => {
beforeEach(() => {
Expand Down Expand Up @@ -95,17 +91,16 @@ describe('memoizedNumberFormatter()', () => {
},
);

/* eslint-disable jest/no-if */
it.each`
locale | expectedValue | expectedLocale
${'en-US'} | ${'$1.23'} | ${'en-US-u-nu-latn'}
${'fr-CA'} | ${'1,23 $ US'} | ${'fr-CA-u-nu-latn'}
${'zh-Hans-hk'} | ${'US$1.23'} | ${'zh-Hans-HK-u-nu-latn'}
${'ar-EG'} | ${isModernNode ? '\u200F1.23 US$' : 'US$ 1.23'} | ${'ar-EG-u-nu-latn'}
${'ar-EG-u-nu-arab'} | ${isModernNode ? '\u200F1.23 US$' : 'US$ 1.23'} | ${'ar-EG-u-nu-latn'}
${'fa-IR'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-u-nu-arabext-x-ab-cdefg'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-x-ab-cdefg-u-nu-arabext'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
locale | expectedValue | expectedLocale
${'en-US'} | ${'$1.23'} | ${'en-US-u-nu-latn'}
${'fr-CA'} | ${'1,23 $ US'} | ${'fr-CA-u-nu-latn'}
${'zh-Hans-hk'} | ${'US$1.23'} | ${'zh-Hans-HK-u-nu-latn'}
${'ar-EG'} | ${'\u200F1.23 US$'} | ${'ar-EG-u-nu-latn'}
${'ar-EG-u-nu-arab'} | ${'\u200F1.23 US$'} | ${'ar-EG-u-nu-latn'}
${'fa-IR'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-u-nu-arabext-x-ab-cdefg'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
${'fa-IR-x-ab-cdefg-u-nu-arabext'} | ${'\u200E$ 1.23'} | ${'fa-IR-u-nu-latn'}
`(
'returns formatted currency in the $locale locale, falling back to appending the latin numbering system',
({locale, expectedValue, expectedLocale}) => {
Expand All @@ -120,7 +115,6 @@ describe('memoizedNumberFormatter()', () => {
);
},
);
/* eslint-enable jest/no-if */
});
});

Expand Down
11 changes: 6 additions & 5 deletions packages/storybook-a11y-test/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ describe('can test a story', () => {

beforeAll(() => {
return new Promise((resolve, reject) => {
// node 18 and webpack 4 do not play nice together.
// node 18/20 and webpack 4 do not play nice together.
// this can be removed once we update storybook to v7, and thus
// remove the dependency on webpack 4
const env = process.version.startsWith('v18.')
? // eslint-disable-next-line no-process-env
{...process.env, NODE_OPTIONS: '--openssl-legacy-provider'}
: undefined;
const env =
process.version.startsWith('v18.') || process.version.startsWith('v20.')
? // eslint-disable-next-line no-process-env
{...process.env, NODE_OPTIONS: '--openssl-legacy-provider'}
: undefined;

exec(
`yarn run build-storybook`,
Expand Down

0 comments on commit 2fc9074

Please sign in to comment.