Skip to content
Snippets Groups Projects
Commit 06489173 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'rtl/partner-issue' into 'dev'

test(rtl): partner issue

See merge request !1054
parents 77d2a015 d16b2cfd
No related branches found
No related tags found
2 merge requests!10622.7 Release,!1054test(rtl): partner issue
import { Button } from '@material-ui/core'
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { FluidType } from 'enums'
import { mount } from 'enzyme'
import toJson from 'enzyme-to-json'
import React from 'react'
import PartnerIssueModal from './PartnerIssueModal'
const mockHandleClose = jest.fn()
describe('PartnerIssueModal component', () => {
it('should render correctly', () => {
const wrapper = mount(
const { baseElement } = render(
<PartnerIssueModal
open={true}
handleCloseClick={mockHandleClose}
issuedFluid={FluidType.ELECTRICITY}
/>
)
expect(toJson(wrapper)).toMatchSnapshot()
expect(screen.getByRole('dialog')).toBeInTheDocument()
expect(baseElement).toMatchSnapshot()
})
it('should render elec modal', () => {
const wrapper = mount(
render(
<PartnerIssueModal
open={true}
handleCloseClick={mockHandleClose}
issuedFluid={FluidType.ELECTRICITY}
/>
)
expect(wrapper.text().includes('error_connect_elec')).toBeTruthy()
expect(
screen.getByText('consumption.partner_issue_modal.error_connect_elec')
).toBeInTheDocument()
})
it('should render water modal', () => {
const wrapper = mount(
render(
<PartnerIssueModal
open={true}
handleCloseClick={mockHandleClose}
issuedFluid={FluidType.WATER}
/>
)
expect(wrapper.text().includes('error_connect_water')).toBeTruthy()
expect(
screen.getByText('consumption.partner_issue_modal.error_connect_water')
).toBeInTheDocument()
})
it('should close modal', () => {
const wrapper = mount(
it('should close modal', async () => {
render(
<PartnerIssueModal
open={true}
handleCloseClick={mockHandleClose}
issuedFluid={FluidType.ELECTRICITY}
/>
)
wrapper.find(Button).simulate('click')
await userEvent.click(screen.getAllByRole('button')[0])
expect(mockHandleClose).toHaveBeenCalled()
})
it('should not be rendered', () => {
const wrapper = mount(
render(
<PartnerIssueModal
open={false}
handleCloseClick={mockHandleClose}
issuedFluid={FluidType.ELECTRICITY}
/>
)
expect(wrapper.find('div.partnerIssueModal').exists()).toBeFalsy()
expect(screen.queryByRole('dialog')).toBeFalsy()
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment