Skip to content
Snippets Groups Projects
Commit f5c37598 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

Add unsubsribe test

parent 713a873b
Branches
Tags
1 merge request!367Feat/us469 unsubscribe bilan
import React from 'react'
import { mount } from 'enzyme'
import { Provider } from 'react-redux'
import {
createMockStore,
mockInitialEcolyoState,
} from '../../../tests/__mocks__/store'
import * as profileActions from 'store/profile/profile.actions'
import UnSubscribe from './UnSubscribe'
import { Button } from '@material-ui/core'
jest.mock('cozy-ui/transpiled/react/I18n', () => {
return {
useI18n: jest.fn(() => {
return {
t: (str: string) => str,
}
}),
}
})
const mockUpdateProfile = jest.fn()
jest.mock('services/profile.service', () => {
return jest.fn(() => {
return {
updateProfile: mockUpdateProfile,
}
})
})
// const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch')
const updateProfileSpy = jest.spyOn(profileActions, 'updateProfile')
describe('UnSubscribe component', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let store: any
beforeEach(() => {
store = createMockStore(mockInitialEcolyoState)
updateProfileSpy.mockClear()
})
it('should be rendered correctly', () => {
const wrapper = mount(
<Provider store={store}>
<UnSubscribe />
</Provider>
).getElement()
expect(wrapper).toMatchSnapshot()
})
it('should click on button and deactivate report', () => {
const wrapper = mount(
<Provider store={store}>
<UnSubscribe />
</Provider>
)
wrapper.find(Button).simulate('click')
expect(updateProfileSpy).toHaveBeenCalledWith({
sendAnalysisNotification: false,
})
})
})
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UnSubscribe component should be rendered correctly 1`] = `
<Provider
store={
Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
}
}
>
<UnSubscribe />
</Provider>
`;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment