);
}
describe(' integration', () => {
const { render } = createRenderer();
it('should not be open', () => {
render();
expect(screen.queryAllByRole('menu')).to.have.length(0);
});
it('should focus the first item of the first menu when nothing has been selected', () => {
render();
expect(screen.getByRole('menu')).to.have.id('first-menu');
expect(within(screen.getByRole('menu')).getAllByRole('menuitem')[0]).toHaveFocus();
});
it('should focus the first item of the second menu when nothing has been selected', () => {
render();
expect(screen.getByRole('menu')).to.have.id('second-menu');
expect(within(screen.getByRole('menu')).getAllByRole('menuitem')[0]).toHaveFocus();
});
it('should open the first menu after it was closed', () => {
const { setProps } = render();
setProps({ firstMenuOpen: false });
setProps({ firstMenuOpen: true });
expect(screen.getByRole('menu')).to.have.id('first-menu');
expect(within(screen.getByRole('menu')).getAllByRole('menuitem')[0]).toHaveFocus();
});
it('should be able to open second menu again', () => {
const { setProps } = render();
setProps({ secondMenuOpen: false });
setProps({ secondMenuOpen: true });
expect(screen.getByRole('menu')).to.have.id('second-menu');
expect(within(screen.getByRole('menu')).getAllByRole('menuitem')[0]).toHaveFocus();
});
});