Newer
Older
import { act, render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import ChallengeCardLast from './ChallengeCardLast'

Marlène SIMONDANT
committed
// Value coming from jest.config
declare let __SAU_IDEA_DIRECT_LINK__: string

Marlène SIMONDANT
committed
describe('ChallengeCardLast component', () => {
it('should be rendered correctly', () => {
const { container } = render(<ChallengeCardLast />)
expect(container).toMatchSnapshot()

Marlène SIMONDANT
committed
})
await act(async () => {
await userEvent.click(screen.getByText('challenge.card_last.button'))
})
expect(window.open).toHaveBeenCalledTimes(1)
expect(global.open).toHaveBeenCalledWith(
`${__SAU_IDEA_DIRECT_LINK__}?version=0.0.0`
)
})