Skip to content
Snippets Groups Projects
DataShareConsentContent.spec.tsx 1.25 KiB
import React from 'react'
import { mount } from 'enzyme'
import toJson from 'enzyme-to-json'
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 />
      </Provider>
    )
    expect(toJson(component)).toMatchSnapshot()
  })
  it('should be rendered correctly without first connexion text', () => {
    profileData.isFirstConnection = false
    const store = mockStore({
      ecolyo: {
        profile: profileData,
      },
    })
    const component = mount(
      <Provider store={store}>
        <DataShareConsentContent />
      </Provider>
    )
    expect(toJson(component)).toMatchSnapshot()
  })
})