Created
June 29, 2022 21:19
-
-
Save ruanlinos/dadd87ad0dfbef5aa1e43832442e217b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import {Provider} from 'react-redux' | |
import configureStore from 'redux-mock-store' | |
import {shallow, mount} from "enzyme"; | |
import AddTool from "../AddTool"; | |
import withProvider from "../../../hoc/with-provider"; | |
import {render, screen, waitFor} from '@testing-library/react' | |
import userEvent from '@testing-library/user-event' | |
describe('Add tool testing', () => { | |
const initialState = { | |
tools: [{ | |
id: '1', | |
name: 'Tool 1', | |
link: 'https://www.google.com', | |
description: 'Description 1', | |
tags: [{ | |
id: '1', | |
name: 'Tag 1' | |
}] | |
}], | |
toolsSearch: [], | |
isOnlyTag: false, | |
openModalAdd: false | |
} | |
const mockStore = configureStore() | |
const store = mockStore(initialState) | |
const Component = withProvider(AddTool, store) | |
it('should match with snapshot', () => { | |
const renderedComponent = shallow( | |
<Component/> | |
) | |
expect(renderedComponent).toMatchSnapshot() | |
}) | |
it('should test AddTool component', () => { | |
const renderedComponent = mount( | |
<Component/> | |
) | |
renderedComponent.find("#submit-button") | |
.at(0) | |
.simulate("click") | |
}) | |
it('should render error when submit form', () => { | |
const componentRender = mount(<Component/>) | |
componentRender.find("#submit-button").at(0).simulate("click") | |
}) | |
it('should be able to click in cancel button', () => { | |
const componentRender = mount(<Component/>) | |
componentRender.find("#cancel-modal").at(0).simulate("click") | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment