Public Access
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[]).
45 lines
1.7 KiB
React
45 lines
1.7 KiB
React
// @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();
|
|
});
|
|
});
|