19 lines
799 B
TypeScript
19 lines
799 B
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import { EntrySelectionDialog } from './EntrySelectionDialog';
|
|
|
|
describe('EntrySelectionDialog', () => {
|
|
it('父组件重渲染时不抢走入口按钮焦点,且不暴露无效关闭动作', () => {
|
|
const entries = [
|
|
{ path: 'a.xml', label: '模型 A' },
|
|
{ path: 'b.xml', label: '模型 B' },
|
|
],
|
|
select = vi.fn();
|
|
const { rerender } = render(<EntrySelectionDialog entries={entries} onSelect={select} />);
|
|
const entry = screen.getByRole('button', { name: '模型 A' });
|
|
entry.focus();
|
|
rerender(<EntrySelectionDialog entries={[...entries]} onSelect={select} />);
|
|
expect(entry).toHaveFocus();
|
|
expect(screen.queryByRole('button', { name: '关闭' })).not.toBeInTheDocument();
|
|
});
|
|
});
|