PronounsPage/test/flags.test.ts
2024-05-13 12:18:40 +02:00

22 lines
831 B
TypeScript

import { expect, test } from '@jest/globals';
import fs from 'fs';
import { buildFlags, flags } from '../src/flags.ts';
const __dirname = new URL('.', import.meta.url).pathname;
test('flags correspond to static image files', () => {
const expectedFlagNames = fs.readdirSync(`${__dirname}/../static/flags/`)
.filter((flagName) => {
return !flagName.startsWith('.') && !flagName.startsWith('_');
})
.map((flagName) => flagName.replace(/\.png$/, ''));
expect(Object.keys(flags)).toEqual(expectedFlagNames);
});
test('building flags removes locale foreign flags', () => {
const flags = buildFlags('en');
expect(Object.keys(flags)).toContain('-en-Genderdoe');
expect(Object.keys(flags)).not.toContain('-Drag');
expect(Object.keys(flags)).not.toContain('-pl-Dukaizmy');
});