@navinc/base-react-components
Version:
Nav's Pattern Library
27 lines (21 loc) • 959 B
JavaScript
import React from 'react'
import { renderWithContext, screen } from '../tests/with-app-context.js'
import { Icon, InteractiveIcon } from './icon.js'
describe('Icon', () => {
it('renders a svg if a proper name is supplied', async () => {
renderWithContext(<Icon name="actions/close" />)
const icon = await screen.findByTestId('icon:actions/close')
expect(icon).toBeInTheDocument()
})
})
describe('InteractiveIcon', () => {
it('renders a svg if a proper name is supplied and no warning when using event handler', async () => {
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
renderWithContext(<InteractiveIcon name="actions/close" onClick={() => {}} />)
const icon = await screen.findByTestId('icon:actions/close')
const button = await screen.findByTestId('interactive-icon')
expect(icon).toBeInTheDocument()
expect(button).toBeInTheDocument()
expect(warn).not.toHaveBeenCalled()
})
})