2020-09-21 10:14:36 -04:00
|
|
|
import { expect } from 'chai'
|
|
|
|
import { screen, render } from '@testing-library/react'
|
|
|
|
|
|
|
|
import Icon from '../../../../frontend/js/shared/components/icon'
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('<Icon />', function () {
|
|
|
|
it('renders basic fa classes', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
const { container } = render(<Icon type="angle-down" />)
|
|
|
|
const element = container.querySelector('i.fa.fa-angle-down')
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders with aria-hidden', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
const { container } = render(<Icon type="angle-down" />)
|
|
|
|
const element = container.querySelector('i[aria-hidden="true"]')
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders accessible label', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
render(<Icon type="angle-down" accessibilityLabel="Accessible Foo" />)
|
|
|
|
screen.getByText('Accessible Foo')
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders with spin', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
const { container } = render(<Icon type="angle-down" spin />)
|
|
|
|
const element = container.querySelector('i.fa.fa-angle-down.fa-spin')
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders with modifier', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
const { container } = render(<Icon type="angle-down" modifier="2x" />)
|
|
|
|
const element = container.querySelector('i.fa.fa-angle-down.fa-2x')
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders with custom clases', function () {
|
2020-09-21 10:14:36 -04:00
|
|
|
const { container } = render(
|
|
|
|
<Icon type="angle-down" classes={{ icon: 'custom-icon-class' }} />
|
|
|
|
)
|
|
|
|
const element = container.querySelector(
|
|
|
|
'i.fa.fa-angle-down.custom-icon-class'
|
|
|
|
)
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
2020-11-26 09:22:30 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('renders children', function () {
|
2020-11-26 09:22:30 -05:00
|
|
|
const { container } = render(
|
|
|
|
<Icon type="angle-down">
|
|
|
|
<Icon type="angle-up" />
|
|
|
|
</Icon>
|
|
|
|
)
|
|
|
|
const element = container.querySelector(
|
|
|
|
'i.fa.fa-angle-down > i.fa.fa-angle-up'
|
|
|
|
)
|
|
|
|
expect(element).to.exist
|
|
|
|
})
|
2020-09-21 10:14:36 -04:00
|
|
|
})
|