@navinc/base-react-components
Version:
Nav's Pattern Library
20 lines (18 loc) • 817 B
JavaScript
import { screen, fireEvent } from '@testing-library/react'
import { renderWithContext } from './tests/with-app-context.js'
import { CardInsight } from './card-insight.js'
describe('<CardInsight />', () => {
it('renders Link if an action is supplied', () => {
const { getRouteProps } = renderWithContext(<CardInsight actionHref="/asdf" actionLabel="asdf" />)
fireEvent.click(screen.getByText(/asdf/i))
expect(getRouteProps().location.pathname).toBe('/asdf')
})
it('renders the copy if copy is given', () => {
renderWithContext(<CardInsight copy="Beets" />)
expect(screen.getByText(/beets/i)).toBeInTheDocument()
})
it('renders the title if a title is given', () => {
renderWithContext(<CardInsight title="Bears" />)
expect(screen.getByText(/bears/i)).toBeInTheDocument()
})
})