diff --git a/rtl-spec/components/editors-non-ideal-state.spec.tsx b/rtl-spec/components/editors-non-ideal-state.spec.tsx new file mode 100644 index 0000000000..29d5e84f1d --- /dev/null +++ b/rtl-spec/components/editors-non-ideal-state.spec.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import { render } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; + +import { RenderNonIdealState } from '../../src/renderer/components/editors-non-ideal-state'; +import { EditorMosaic } from '../../src/renderer/editor-mosaic'; + +describe('RenderNonIdealState component', () => { + let editorMosaic: EditorMosaic; + + beforeEach(() => { + ({ editorMosaic } = window.app.state); + }); + + it('renders a non-ideal state', () => { + const { getByText } = render( + , + ); + + expect(getByText('Reset editors')).toBeInTheDocument(); + }); + + it('handles a click', async () => { + const resetLayoutSpy = jest.spyOn(editorMosaic, 'resetLayout'); + const { getByRole } = render( + , + ); + await userEvent.click(getByRole('button')); + + expect(resetLayoutSpy).toHaveBeenCalledTimes(1); + }); +}); diff --git a/src/renderer/components/editors-non-ideal-state.tsx b/src/renderer/components/editors-non-ideal-state.tsx index 386b6a8f6a..f58ba35081 100644 --- a/src/renderer/components/editors-non-ideal-state.tsx +++ b/src/renderer/components/editors-non-ideal-state.tsx @@ -4,7 +4,13 @@ import { Button, NonIdealState } from '@blueprintjs/core'; import { EditorMosaic } from '../editor-mosaic'; -export function renderNonIdealState(editorMosaic: EditorMosaic) { +type RenderNonIdealStateProps = { + editorMosaic: EditorMosaic; +}; + +export function RenderNonIdealState({ + editorMosaic, +}: RenderNonIdealStateProps) { const resolveButton = (