-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add react testing library, wrapper for redux store provider, and impl…
…ement an input test
- Loading branch information
Showing
8 changed files
with
299 additions
and
33 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// https://testing-library.com/docs/react-testing-library/setup/ | ||
// https://redux.js.org/usage/writing-tests#components | ||
|
||
import React from 'react' | ||
import {render as rtlRender } from '@testing-library/react'; | ||
import { Provider } from 'react-redux'; | ||
import { store } from './redux/store'; | ||
|
||
const render = ( | ||
ui, | ||
{ | ||
preloadedState, | ||
...renderOptions | ||
} = {} | ||
) => { | ||
const Wrapper = ({ children }) => { | ||
return <Provider store={store}>{children}</Provider> | ||
} | ||
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions}) | ||
} | ||
|
||
export * from '@testing-library/react'; | ||
export { render } |
13 changes: 13 additions & 0 deletions
13
src/features/book/components/book-form/__test__/book-form.test.js
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { render, screen } from '../../../../_global/test-utils' | ||
import BookForm from '../book-form.component' | ||
|
||
describe('BookForm', () => { | ||
it('should render BookForm', async () => { | ||
render( | ||
<BookForm /> | ||
) | ||
const inputElement = screen.getByPlaceholderText('name'); | ||
expect(inputElement).toBeInTheDocument() | ||
}) | ||
}) |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
// import { configure } from 'enzyme'; | ||
// import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
configure({ | ||
adapter: new Adapter() | ||
}) | ||
// configure({ | ||
// adapter: new Adapter() | ||
// }) | ||
|
||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom'; |
Oops, something went wrong.