Skip to content
Snippets Groups Projects
DataShareConsentContent.spec.tsx 1.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Guilhem CARRON's avatar
    Guilhem CARRON committed
    import { mount } from 'enzyme'
    
    import toJson from 'enzyme-to-json'
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    import { Provider } from 'react-redux'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { createMockEcolyoStore } from '../../../tests/__mocks__/store'
    
    import DataShareConsentContent from './DataShareConsentContent'
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    jest.mock('cozy-ui/transpiled/react/I18n', () => ({
      useI18n: jest.fn(() => ({
        t: (str: string) => str,
      })),
    }))
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    describe('DataShareConsentContent component', () => {
      it('should be rendered correctly with first connexion text', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore({
          profile: { isFirstConnection: true },
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
        })
        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', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore({
          profile: { isFirstConnection: false },
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
        })
        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
      })
    })