Files
ToBePlayed-Frontend/src/components/TimeToBeat.test.jsx
T

27 lines
999 B
React

// @vitest-environment jsdom
import {afterEach, describe, expect, it, vi} from 'vitest';
import {cleanup, render, screen} from '@testing-library/react';
import TimeToBeat from './TimeToBeat.jsx';
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
describe('TimeToBeat', () => {
afterEach(cleanup);
it('shows the known times', () => {
render(<TimeToBeat time={{hastilyMinutes: 510, normallyMinutes: 750, completelyMinutes: null}}/>);
expect(screen.getByText('8.5h')).toBeTruthy();
expect(screen.getByText('13h')).toBeTruthy();
expect(screen.queryByText('GAME_DETAIL.TTB_COMPLETELY')).toBeNull();
});
it('renders nothing without data', () => {
const {container} = render(<TimeToBeat time={{hastilyMinutes: null, normallyMinutes: null, completelyMinutes: null}}/>);
expect(container.textContent).toBe('');
cleanup();
expect(render(<TimeToBeat time={null}/>).container.textContent).toBe('');
});
});