feat(library): add platform badges, remove hide duplicates

Gitea #34 slice 2 of 3. Core lists each set once now.
The hide duplicates toggle and its param are not needed.
PlatformIcons shows a badge per platform (platforms[]).
This commit is contained in:
lobo committed 2026-10-09 11:31:11 +02:00
1 parent 25cc5ff2d8
commit 16651a1f56
13 files changed
+120 -48

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
// @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(<PlatformIcons platforms={[{source: 'STEAM', platform: null}, {source: 'PSN', platform: 'PS5'}]}/>);
expect(screen.getAllByRole('listitem')).toHaveLength(2);
expect(screen.getByLabelText('Steam').textContent).toBe('ST');
expect(screen.getByLabelText('PS5').textContent).toBe('PS5');
});
it('namesAPlayStationTitleWithoutPlatformAfterItsSource', () => {
render(<PlatformIcons platforms={[{source: 'PSN', platform: null}]}/>);
expect(screen.getByLabelText('LIBRARY.SOURCE.PSN').textContent).toBe('PS');
});
it('showsAManualPlatformByName', () => {
render(<PlatformIcons platforms={[{source: 'MANUAL', platform: 'Switch'}]}/>);
expect(screen.getByLabelText('Switch').textContent).toBe('Switch');
});
it('aManualGameWithoutPlatformIsNotShownAsPlayStation', () => {
render(<PlatformIcons platforms={[{source: 'MANUAL', platform: null}]}/>);
expect(screen.getByLabelText('LIBRARY.SOURCE.MANUAL').textContent).not.toBe('PS');
});
it('rendersNothingWithoutPlatforms', () => {
const {container} = render(<PlatformIcons platforms={[]}/>);
expect(container.firstChild).toBeNull();
cleanup();
const missing = render(<PlatformIcons/>);
expect(missing.container.firstChild).toBeNull();
});
});