@neiderruiz/translate-files
Version:
Internationalize and manage your website easily with (CSV or JSON to i18n)
18 lines (16 loc) • 565 B
text/typescript
import {describe, expect, test} from '@jest/globals';
import { sortByLanguage } from '../src/utils/sort-by-language';
describe('sortByLanguage', () => {
test('sorts JSON by language', () => {
const input = [
{ key: 'hello', en: 'hello', es: 'hola' },
{ key: 'world', en: 'world', es: 'mundo' },
];
const output = [
{ key: { hello: 'hello', world: 'world' } },
{ en: { hello: 'hello', world: 'world' } },
{ es: { hello: 'hola', world: 'mundo' } }
];
expect(sortByLanguage(input)).toEqual(output);
});
});