Skip to content
Snippets Groups Projects
DataShareConsentContent.spec.tsx 1.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • Guilhem CARRON's avatar
    Guilhem CARRON committed
    import React from 'react'
    import { mount } from 'enzyme'
    
    import toJson from 'enzyme-to-json'
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    import DataShareConsentContent from './DataShareConsentContent'
    import { profileData } from '../../../tests/__mocks__/profile.mock'
    import configureStore from 'redux-mock-store'
    import { Provider } from 'react-redux'
    
    jest.mock('cozy-ui/transpiled/react/I18n', () => {
      return {
        useI18n: jest.fn(() => {
          return {
            t: (str: string) => str,
          }
        }),
      }
    })
    const mockStore = configureStore([])
    
    describe('DataShareConsentContent component', () => {
      it('should be rendered correctly with first connexion text', () => {
        const store = mockStore({
          ecolyo: {
            profile: profileData,
          },
        })
        const component = mount(
          <Provider store={store}>
    
            <DataShareConsentContent />
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
          </Provider>
    
        )
        expect(toJson(component)).toMatchSnapshot()
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
      })
    
      it('should be rendered correctly without first connexion text', () => {
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
        profileData.isFirstConnection = false
        const store = mockStore({
          ecolyo: {
            profile: profileData,
          },
        })
        const component = mount(
          <Provider store={store}>
    
            <DataShareConsentContent />
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
          </Provider>
        )
    
        expect(toJson(component)).toMatchSnapshot()
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
      })
    })