-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrate
editors-non-ideal-state
test to RTL
- Loading branch information
Showing
4 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { renderNonIdealState } from '../../src/renderer/components/editors-non-ideal-state'; | ||
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()', () => { | ||
describe('RenderNonIdealState component', () => { | ||
let editorMosaic: EditorMosaic; | ||
|
||
beforeEach(() => { | ||
({ editorMosaic } = window.app.state); | ||
}); | ||
|
||
it('renders a non-ideal state', () => { | ||
expect(renderNonIdealState({} as EditorMosaic)).toMatchSnapshot(); | ||
const { getByText } = render( | ||
<RenderNonIdealState editorMosaic={{} as EditorMosaic} />, | ||
); | ||
|
||
expect(getByText('Reset editors')).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles a click', () => { | ||
it('handles a click', async () => { | ||
const resetLayoutSpy = jest.spyOn(editorMosaic, 'resetLayout'); | ||
const wrapper = mount(renderNonIdealState(editorMosaic)); | ||
wrapper.find('button').simulate('click'); | ||
const { getByRole } = render( | ||
<RenderNonIdealState editorMosaic={editorMosaic} />, | ||
); | ||
await userEvent.click(getByRole('button')); | ||
|
||
expect(resetLayoutSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
tests/renderer/components/__snapshots__/editors-non-ideal-state-spec.tsx.snap
This file was deleted.
Oops, something went wrong.