diff --git a/src/components/Options/ReportOptions.spec.tsx b/src/components/Options/ReportOptions.spec.tsx index 18ba683667b00fe50fcb73b33eaf52541400f5ad..65778d6110d62c7a5ff360a3f6d12c40901a0a58 100644 --- a/src/components/Options/ReportOptions.spec.tsx +++ b/src/components/Options/ReportOptions.spec.tsx @@ -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, + }) + }) }) diff --git a/src/services/mail.service.spec.ts b/src/services/mail.service.spec.ts index 4107a45048779240d1d6c97298cb519eb50d8dd7..265def8d018dce1c8b99c7de2220e0a86c648b30 100644 --- a/src/services/mail.service.spec.ts +++ b/src/services/mail.service.spec.ts @@ -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>' ) ) })