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

Fix + improve report and mail test

parent 70ad8405
No related branches found
No related tags found
1 merge request!367Feat/us469 unsubscribe bilan
......@@ -7,7 +7,7 @@ import {
mockInitialEcolyoState,
} from '../../../tests/__mocks__/store'
import * as profileActions from 'store/profile/profile.actions'
import StyledSwitch from 'components/CommonKit/Switch/StyledSwitch'
import { Button } from '@material-ui/core'
jest.mock('cozy-ui/transpiled/react/I18n', () => {
return {
......@@ -44,13 +44,7 @@ describe('ReportOptions component', () => {
<ReportOptions />
</Provider>
)
expect(wrapper.find(StyledSwitch)).toHaveLength(1)
expect(
wrapper
.find(StyledSwitch)
.first()
.props().checked
).toBeFalsy()
expect(wrapper.find(Button).text()).toBe('profile.report.activate')
})
it('should update the profile with sendAnalysisNotification to true', () => {
......@@ -60,12 +54,30 @@ describe('ReportOptions component', () => {
</Provider>
)
wrapper
.find('input')
.find(Button)
.first()
.simulate('change', { target: { checked: 'true' } })
.simulate('click')
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
sendAnalysisNotification: true,
})
})
it('should be rendered with sendAnalysisNotification true and toggle it to false', () => {
mockInitialEcolyoState.profile.sendAnalysisNotification = true
store = createMockStore(mockInitialEcolyoState)
const wrapper = mount(
<Provider store={store}>
<ReportOptions />
</Provider>
)
wrapper
.find(Button)
.first()
.simulate('click')
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
sendAnalysisNotification: false,
})
})
})
......@@ -8,7 +8,7 @@ describe('Mail service', () => {
it('should return void when mail is sent', async () => {
const mockMailData = {
mode: 'noreply',
subject: '[Ecolyo] - Bienvenu',
subject: '[Ecolyo] - Bienvenue',
parts: [
{
type: 'text/html',
......@@ -24,7 +24,7 @@ describe('Mail service', () => {
let error
const mockMailData = {
mode: 'noreply',
subject: '[Ecolyo] - Bienvenu',
subject: '[Ecolyo] - Bienvenue',
parts: [
{
type: 'text/html',
......@@ -95,7 +95,7 @@ describe('Mail service', () => {
)
expect(result).toEqual(
expect.stringContaining(
'<a href="https://user-ecolyo.test.com/#/options" style="color: #ffffff">Unsubscribe</a>'
'<a href="https://user-ecolyo.test.com/#/unsubscribe" style="color: #ffffff">Unsubscribe</a>'
)
)
})
......@@ -113,7 +113,7 @@ describe('Mail service', () => {
)
expect(result).toEqual(
expect.stringContaining(
'<a href="https://user-ecolyo.test.com/#/options" style="color: #ffffff">Unsubscribe</a>'
'<a href="https://user-ecolyo.test.com/#/unsubscribe" style="color: #ffffff">Unsubscribe</a>'
)
)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment