Skip to content
Snippets Groups Projects
Navbar.spec.tsx 1.69 KiB
Newer Older
  • Learn to ignore specific revisions
  • Bastien DUMONT's avatar
    Bastien DUMONT committed
    import Navbar from 'components/Navbar/Navbar'
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    import { mount } from 'enzyme'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import React from 'react'
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    import { Provider } from 'react-redux'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { BrowserRouter } from 'react-router-dom'
    
    import { createMockEcolyoStore } from 'tests/__mocks__/store'
    
    
    describe('Navbar component', () => {
    
    Yoan VALLET's avatar
    Yoan VALLET committed
      it('should be rendered correctly with 5 navlink', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore()
    
    Yoan VALLET's avatar
    Yoan VALLET committed
        const wrapper = mount(
          <Provider store={store}>
            <BrowserRouter>
              <Navbar />
            </BrowserRouter>
          </Provider>
        )
        expect(wrapper.find('NavLink')).toHaveLength(5)
      })
    
    
      it('should be rendered correctly with notifications', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore({
          global: {
            challengeExplorationNotification: true,
            challengeActionNotification: false,
            challengeDuelNotification: false,
            analysisNotification: true,
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          },
        })
        const wrapper = mount(
          <Provider store={store}>
            <BrowserRouter>
              <Navbar />
            </BrowserRouter>
          </Provider>
        )
    
        expect(wrapper.find('.nb-notif').first().text()).toEqual('1')
        expect(wrapper.find('.nb-notif').last().text()).toEqual('1')
    
      })
    
      it('should be rendered correctly without notifications', () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const store = createMockEcolyoStore({
          global: {
            challengeExplorationNotification: false,
            challengeActionNotification: false,
            challengeDuelNotification: false,
            analysisNotification: false,
    
    Yoan VALLET's avatar
    Yoan VALLET committed
          },
        })
        const wrapper = mount(
          <Provider store={store}>
            <BrowserRouter>
              <Navbar />
            </BrowserRouter>
          </Provider>
        )
        expect(wrapper.find('.nb-notif').exists()).toBeFalsy()