@navinc/base-react-components
Version:
Nav's Pattern Library
21 lines (19 loc) • 844 B
JavaScript
import React from 'react'
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()
})
})