72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
||
import { describe, it, expect } from 'vitest';
|
||
import { ExerciseEditor } from '../src/pages/plans/plan-editor/ExerciseEditor';
|
||
import type { EditorExercise } from '../src/pages/plans/plan-editor/types';
|
||
import type { Exercise } from '../src/api/types';
|
||
|
||
const LONG_NAME = 'Wiosłowanie sztangą nachwytem w pełnym opadzie tułowia';
|
||
|
||
const EXERCISE: EditorExercise = {
|
||
exerciseId: 'ex-1',
|
||
sets: [{ reps: '10', loadKg: '50', restSec: '90', rir: '2' }],
|
||
};
|
||
|
||
const META = { id: 'ex-1', name: LONG_NAME, primaryMuscle: 'core' } as Exercise;
|
||
|
||
function renderEditor(exerciseMeta?: Exercise, exercise: EditorExercise = EXERCISE) {
|
||
return render(
|
||
<ExerciseEditor
|
||
exercise={exercise}
|
||
exerciseMeta={exerciseMeta}
|
||
exerciseName={() => LONG_NAME}
|
||
isTraineeMode={false}
|
||
resultsOpen={false}
|
||
onToggleResults={() => {}}
|
||
onRemove={() => {}}
|
||
onMoveUp={() => {}}
|
||
onMoveDown={() => {}}
|
||
canMoveUp={false}
|
||
canMoveDown={false}
|
||
onSetField={() => {}}
|
||
onAddSetCopy={() => {}}
|
||
onRemoveSet={() => {}}
|
||
latest={undefined}
|
||
points={[]}
|
||
onPrefill={() => {}}
|
||
/>,
|
||
);
|
||
}
|
||
|
||
describe('ExerciseEditor — długa nazwa ćwiczenia', () => {
|
||
it('nazwa i podsumowanie serii łamią się zamiast być przycinane', () => {
|
||
renderEditor();
|
||
|
||
const name = screen.getByText(LONG_NAME);
|
||
expect(name.tagName).toBe('STRONG');
|
||
expect(name).toHaveClass('break-words');
|
||
expect(name).not.toHaveClass('truncate');
|
||
|
||
const summary = screen.getByText('1×10 @ 50 kg · RIR 2');
|
||
expect(summary).toHaveClass('whitespace-nowrap');
|
||
expect(summary).not.toHaveClass('truncate');
|
||
});
|
||
|
||
it('badge mięśnia i podsumowanie tworzą jedną grupę łamaną razem', () => {
|
||
renderEditor(META);
|
||
|
||
const name = screen.getByText(LONG_NAME);
|
||
const badge = screen.getByText('Core');
|
||
const summary = screen.getByText('1×10 @ 50 kg · RIR 2');
|
||
expect(badge.parentElement).toBe(summary.parentElement);
|
||
expect(name.parentElement).not.toBe(summary.parentElement);
|
||
});
|
||
|
||
it('seria bez obciążenia: podsumowanie informuje o masie ciała', () => {
|
||
renderEditor(undefined, {
|
||
exerciseId: 'ex-1',
|
||
sets: [{ reps: '12', loadKg: '', restSec: '', rir: '' }],
|
||
});
|
||
expect(screen.getByText('1×12 @ masa ciała')).toBeInTheDocument();
|
||
});
|
||
});
|