feat(web-platform): release V0.9.3 全模块界面重构
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { SimulationControls } from './SimulationControls';
|
||||
describe('SimulationControls', () => {
|
||||
it('迁移后保留播放、单步、重置、速度及就绪限制', () => {
|
||||
const pause = vi.fn(),
|
||||
step = vi.fn(),
|
||||
reset = vi.fn(),
|
||||
speed = vi.fn();
|
||||
const props = {
|
||||
ready: true,
|
||||
paused: true,
|
||||
loading: false,
|
||||
speed: 1,
|
||||
onTogglePause: pause,
|
||||
onStep: step,
|
||||
onReset: reset,
|
||||
onSpeed: speed,
|
||||
};
|
||||
const { rerender } = render(<SimulationControls {...props} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: '▶ 播放' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '单步' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '重置' }));
|
||||
fireEvent.change(screen.getByLabelText('仿真速度'), { target: { value: '2' } });
|
||||
expect(pause).toHaveBeenCalledOnce();
|
||||
expect(step).toHaveBeenCalledOnce();
|
||||
expect(reset).toHaveBeenCalledOnce();
|
||||
expect(speed).toHaveBeenCalledWith(2);
|
||||
rerender(<SimulationControls {...props} paused={false} />);
|
||||
expect(screen.getByRole('button', { name: '⏸ 暂停' })).toBeEnabled();
|
||||
expect(screen.getByRole('button', { name: '单步' })).toBeDisabled();
|
||||
rerender(<SimulationControls {...props} ready={false} />);
|
||||
expect(screen.getByRole('button', { name: '▶ 播放' })).toBeDisabled();
|
||||
expect(screen.getByRole('button', { name: '重置' })).toBeDisabled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user