// @vitest-environment jsdom
import {afterEach, describe, expect, it, vi} from 'vitest';
import {cleanup, render, screen} from '@testing-library/react';
import ComingBadge from './ComingBadge.jsx';
const i18n = vi.hoisted(() => ({language: 'en'}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key, options) => (options?.date ? `${key} ${options.date}` : key),
i18n,
}),
}));
describe('ComingBadge', () => {
afterEach(cleanup);
it('shows the release date in English', () => {
i18n.language = 'en';
render();
expect(screen.getByText('LIBRARY.COMING Dec 4, 2026')).toBeTruthy();
});
it('shows the release date in German', () => {
i18n.language = 'de';
render();
expect(screen.getByText('LIBRARY.COMING 04.12.2026')).toBeTruthy();
});
it('says "coming soon" when the date is unknown', () => {
render();
expect(screen.getByText('LIBRARY.COMING_SOON')).toBeTruthy();
});
it('shows nothing for a released game', () => {
const {container} = render();
expect(container.firstChild).toBeNull();
});
it('shows nothing when an older Core sends no field', () => {
const {container} = render();
expect(container.firstChild).toBeNull();
});
});