Commit 3a077be5 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

update tests

parent ee940931
......@@ -36,6 +36,7 @@ jest.mock('react-router-dom', () => ({
const mockStore = configureStore([])
const mockHandleClose = jest.fn()
const mockHandleLaunchForm = jest.fn()
describe('EcogestureInitModal component', () => {
it('should be rendered correctly', () => {
const store = mockStore({
......@@ -48,12 +49,16 @@ describe('EcogestureInitModal component', () => {
const wrapper = mount(
<Provider store={store}>
<EcogestureInitModal open={true} handleCloseClick={mockHandleClose} />
<EcogestureInitModal
open={true}
handleCloseClick={mockHandleClose}
handleLaunchForm={mockHandleLaunchForm}
/>
</Provider>
)
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should go back ', () => {
it('should close modal ', () => {
const store = mockStore({
ecolyo: {
global: globalStateData,
......@@ -64,16 +69,20 @@ describe('EcogestureInitModal component', () => {
const wrapper = mount(
<Provider store={store}>
<EcogestureInitModal open={true} handleCloseClick={mockHandleClose} />
<EcogestureInitModal
open={true}
handleCloseClick={mockHandleClose}
handleLaunchForm={mockHandleLaunchForm}
/>
</Provider>
)
wrapper
.find(Button)
.first()
.simulate('click')
expect(mockHistoryPush).toHaveBeenCalledWith('/consumption')
expect(mockHandleClose).toHaveBeenCalledTimes(1)
})
it('should close modal and update profile', async () => {
it('should close modal and maunch form', async () => {
const store = mockStore({
ecolyo: {
global: globalStateData,
......@@ -84,13 +93,17 @@ describe('EcogestureInitModal component', () => {
const wrapper = mount(
<Provider store={store}>
<EcogestureInitModal open={true} handleCloseClick={mockHandleClose} />
<EcogestureInitModal
open={true}
handleCloseClick={mockHandleClose}
handleLaunchForm={mockHandleLaunchForm}
/>
</Provider>
)
wrapper
.find(Button)
.at(1)
.simulate('click')
expect(mockHandleClose).toHaveBeenCalledTimes(1)
expect(mockHandleLaunchForm).toHaveBeenCalledTimes(1)
})
})
......@@ -15,6 +15,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
>
<EcogestureInitModal
handleCloseClick={[MockFunction]}
handleLaunchForm={[MockFunction]}
open={true}
>
<WithStyles(ForwardRef(Dialog))
......@@ -861,7 +862,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
"root": "btn-secondary-negative",
}
}
onClick={[Function]}
onClick={[MockFunction]}
>
<ForwardRef(Button)
aria-label="ecogesture.initModal.btn1"
......@@ -899,7 +900,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
"textSizeSmall": "MuiButton-textSizeSmall",
}
}
onClick={[Function]}
onClick={[MockFunction]}
>
<WithStyles(ForwardRef(ButtonBase))
aria-label="ecogesture.initModal.btn1"
......@@ -908,7 +909,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
disabled={false}
focusRipple={true}
focusVisibleClassName="Mui-focusVisible"
onClick={[Function]}
onClick={[MockFunction]}
type="button"
>
<ForwardRef(ButtonBase)
......@@ -925,7 +926,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
disabled={false}
focusRipple={true}
focusVisibleClassName="Mui-focusVisible"
onClick={[Function]}
onClick={[MockFunction]}
type="button"
>
<button
......@@ -933,7 +934,7 @@ exports[`EcogestureInitModal component should be rendered correctly 1`] = `
className="MuiButtonBase-root MuiButton-root btn-secondary-negative MuiButton-text btn1"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onClick={[MockFunction]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
......
......@@ -29,7 +29,7 @@ describe('ProfileEcogesture service', () => {
],
}
const mockQueryResult: QueryResult<ProfileEcogesture> = {
data: mockProfileEcogestureUpdated,
data: [mockProfileEcogestureUpdated],
bookmark: '',
next: false,
skip: 0,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment