UNPKG

@navinc/base-react-components

Version:
25 lines (19 loc) 855 B
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') expect(icon).toBeInTheDocument() expect(warn).not.toHaveBeenCalled() }) })