Skip to content
Snippets Groups Projects
ChallengeCardLast.spec.tsx 793 B
Newer Older
  • Learn to ignore specific revisions
  • import toJson from 'enzyme-to-json'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import React from 'react'
    import ChallengeCardLast from './ChallengeCardLast'
    
    // Value coming from jest.config
    declare let __SAU_IDEA_DIRECT_LINK__: string
    
    
    describe('ChallengeCardLast component', () => {
    
      it('should be rendered correctly', async () => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const wrapper = mount(<ChallengeCardLast />)
    
        expect(toJson(wrapper)).toMatchSnapshot()
    
    
      it('should open SAU new idea link', () => {
        global.open = jest.fn()
    
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        const wrapper = mount(<ChallengeCardLast />)
    
        wrapper.find('.btn_lastCard').first().simulate('click')
    
        expect(window.open).toHaveBeenCalledTimes(1)
    
        expect(global.open).toHaveBeenCalledWith(
          `${__SAU_IDEA_DIRECT_LINK__}?version=0.0.0`
        )
      })