blob: 6a4ff28ccf8ddb0facbdd8dc22d84b0e6f7efc6d (
plain) (
tree)
|
|
import { formatTranslationMessages } from '../i18n';
jest.mock('../translations/en.json', () => ({
message1: 'default message',
message2: 'default message 2',
}));
const esTranslationMessages = {
message1: 'mensaje predeterminado',
message2: '',
};
describe('formatTranslationMessages', () => {
it('should build only defaults when DEFAULT_LOCALE', () => {
const result = formatTranslationMessages('en', { a: 'a' });
expect(result).toEqual({ a: 'a' });
});
it('should combine default locale and current locale when not DEFAULT_LOCALE', () => {
const result = formatTranslationMessages('', esTranslationMessages);
expect(result).toEqual({
message1: 'mensaje predeterminado',
message2: 'default message 2',
});
});
});
|