Add tests for select locale (#10925)

This commit is contained in:
Marvin Frachet 2021-09-10 06:43:06 +02:00 committed by GitHub
parent eacc35eaa1
commit fab2a6f46b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 384 additions and 1 deletions

View File

@ -41,7 +41,18 @@ const LocaleSelect = React.memo(({ value, onLocaleChange, error, onClear }) => {
return (
<Select
startIcon={isLoading ? <SmallLoader>Loading the locales...</SmallLoader> : undefined}
startIcon={
isLoading ? (
<SmallLoader>
{formatMessage({
id: getTrad('Settings.locales.modal.create.defaultLocales.loading'),
defaultMessage: 'Settings.locales.modal.create.defaultLocales.loading',
})}
</SmallLoader>
) : (
undefined
)
}
aria-busy={isLoading}
label={formatMessage({
id: getTrad('Settings.locales.modal.locales.label'),

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,37 @@
import { setupServer } from 'msw/node';
import { rest } from 'msw';
const server = setupServer(
rest.get('*/i18n/iso-locales', (req, res, ctx) => {
const defaultLocales = [
{
code: 'af',
name: 'Afrikaans (af)',
},
{
code: 'en',
name: 'English (en)',
},
{
code: 'fr',
name: 'French (fr)',
},
];
return res(ctx.json(defaultLocales));
}),
rest.get('*/i18n/locales', (req, res, ctx) => {
const defaultLocales = [
{
code: 'en',
name: 'English (en)',
id: 2,
isDefault: true,
},
];
return res(ctx.json(defaultLocales));
})
);
export default server;