Skip to content
Snippets Groups Projects
SgeInit.spec.tsx 962 B
Newer Older
  • Learn to ignore specific revisions
  • Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { render, screen } from '@testing-library/react'
    import { userEvent } from '@testing-library/user-event'
    
    import { Provider } from 'react-redux'
    
    import { createMockEcolyoStore } from 'tests/__mocks__/store'
    
    import SgeInit from './SgeInit'
    
    const mockedNavigate = jest.fn()
    
    jest.mock('react-router-dom', () => ({
      ...jest.requireActual('react-router-dom'),
    
      useNavigate: () => mockedNavigate,
    
    }))
    
    describe('SgeInit component', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      const store = createMockEcolyoStore()
    
      it('should be rendered correctly', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const { container } = render(
    
          <Provider store={store}>
    
            <SgeInit />
    
          </Provider>
        )
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        expect(container).toMatchSnapshot()
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      it('should go to sge connect steps', async () => {
        render(
    
          <Provider store={store}>
    
            <SgeInit />
    
          </Provider>
        )
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        await userEvent.click(screen.getAllByRole('button')[0])
    
        expect(mockedNavigate).toHaveBeenCalled()