import * as React from 'react'; import { forwardRef } from 'react'; import type { Ref } from 'react'; import { render } from '@testing-library/react'; import { InitialFocus } from './InitialFocus'; import { View } from './View'; describe('InitialFocus', () => { it('should focus a text input', async () => { const component = render( , ); // This is needed bc of the `setTimeout` in the `InitialFocus` component. await new Promise(resolve => setTimeout(resolve, 0)); const input = component.getByTitle('focused') as HTMLInputElement; const unfocusedInput = component.getByTitle( 'unfocused', ) as HTMLInputElement; expect(document.activeElement).toBe(input); expect(document.activeElement).not.toBe(unfocusedInput); }); it('should focus a textarea', async () => { const component = render(