2021-04-20 09:41:23 +02:00
|
|
|
'use strict';
|
|
|
|
|
2022-08-08 15:50:34 +02:00
|
|
|
const { getInitLocale } = require('..');
|
2021-04-20 09:41:23 +02:00
|
|
|
|
|
|
|
describe('I18N default locale', () => {
|
|
|
|
describe('getInitLocale', () => {
|
|
|
|
test('The init locale is english by default', () => {
|
2021-04-20 10:52:22 +02:00
|
|
|
expect(getInitLocale()).toStrictEqual({
|
2021-04-20 09:41:23 +02:00
|
|
|
code: 'en',
|
|
|
|
name: 'English (en)',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('The init locale can be configured by an env var', () => {
|
|
|
|
process.env.STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE = 'fr';
|
2021-04-20 10:52:22 +02:00
|
|
|
expect(getInitLocale()).toStrictEqual({
|
2021-04-20 09:41:23 +02:00
|
|
|
code: 'fr',
|
2021-04-20 10:52:22 +02:00
|
|
|
name: 'French (fr)',
|
2021-04-20 09:41:23 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Throws if env var code is unknown in iso list', () => {
|
|
|
|
process.env.STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE = 'zzzzz';
|
|
|
|
expect(() => getInitLocale()).toThrow();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|