/** * Copyright (c) Paymium. * * This source code is licensed under the MIT license found in the * LICENSE file in the root of this projects source tree. */ import { render, fireEvent, screen } from '@crossed/test'; import { FocusScope } from '../FocusScope.web'; describe('FocusScope', () => { test('rend l’enfant passé en prop', () => { render(
Child
); expect(screen.getByTestId('child')).toBeInTheDocument(); }); test('appelle onMountAutoFocus lors du montage', () => { const onMountAutoFocus = jest.fn(); render(
Child
); expect(onMountAutoFocus).toHaveBeenCalled(); }); test('appelle onUnmountAutoFocus lors du démontage', () => { const onUnmountAutoFocus = jest.fn(); const { unmount } = render(
Child
); unmount(); expect(onUnmountAutoFocus).toHaveBeenCalled(); }); test('piège le focus dans le conteneur si trapped est activé', () => { render(
); const button1 = screen.getByTestId('button1'); // const button2 = screen.getByTestId('button2'); button1.focus(); fireEvent.focusOut(button1); expect(button1).toHaveFocus(); }); });