PronounsPage/test/shared/flags.test.ts
Valentyne Stigloher 10180aa6a3 (refactor) use #shared alias instead of ~~/shared
the #shared alias used by Nuxt cannot be easily disabled and to prevent breackage with jiti, we make use of it
2025-08-17 18:56:02 +02:00

24 lines
854 B
TypeScript

import fs from 'node:fs/promises';
import { expect, test } from 'vitest';
import { buildFlags, flags } from '#shared/flags.ts';
const __dirname = new URL('.', import.meta.url).pathname;
test('flags correspond to static image files', async () => {
const expectedFlagNames = (await fs.readdir(`${__dirname}/../../public/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');
});