// @vitest-environment jsdom
import {afterEach, describe, expect, it, vi} from 'vitest';
import {cleanup, render, screen} from '@testing-library/react';
import PlatformIcons from './PlatformIcons.jsx';
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
afterEach(cleanup);
describe('PlatformIcons', () => {
it('showsOneBadgeWithALabelPerPlatform', () => {
render();
expect(screen.getAllByRole('listitem')).toHaveLength(2);
expect(screen.getByLabelText('Steam').textContent).toBe('ST');
expect(screen.getByLabelText('PS5').textContent).toBe('PS5');
});
it('namesAPlayStationTitleWithoutPlatformAfterItsSource', () => {
render();
expect(screen.getByLabelText('LIBRARY.SOURCE.PSN').textContent).toBe('PS');
});
it('showsAManualPlatformByName', () => {
render();
expect(screen.getByLabelText('Switch').textContent).toBe('Switch');
});
it('aManualGameWithoutPlatformIsNotShownAsPlayStation', () => {
render();
expect(screen.getByLabelText('LIBRARY.SOURCE.MANUAL').textContent).not.toBe('PS');
});
it('rendersNothingWithoutPlatforms', () => {
const {container} = render();
expect(container.firstChild).toBeNull();
cleanup();
const missing = render();
expect(missing.container.firstChild).toBeNull();
});
});