123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
- import { renderComponent } from '@tests/support/components'
- import CommonIcon from '../CommonIcon.vue'
- describe('CommonIcon.vue', () => {
- it('renders icon', () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-chevron-left' },
- })
- expect(wrapper.getByIconName('mobile-chevron-left')).toHaveClass('icon')
- expect(wrapper.getByIconName('mobile-chevron-left')).toHaveAttribute(
- 'aria-label',
- 'mobile-chevron-left',
- )
- })
- it('renders icon with animation', () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-settings', animation: 'spin' },
- })
- expect(wrapper.getByIconName('mobile-settings')).toHaveClass('animate-spin')
- })
- it('renders icon with small size', () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-settings', size: 'small' },
- })
- expect(wrapper.getByIconName('mobile-settings')).toHaveAttribute(
- 'width',
- '20',
- )
- expect(wrapper.getByIconName('mobile-settings')).toHaveAttribute(
- 'height',
- '20',
- )
- })
- it('renders a decorative icon', () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-settings', decorative: true },
- })
- expect(wrapper.getByIconName('mobile-settings')).toHaveAttribute(
- 'aria-hidden',
- 'true',
- )
- expect(wrapper.getByIconName('mobile-settings')).not.toHaveAttribute(
- 'aria-label',
- )
- })
- it('triggers click handler of icon', async () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-puzzle' },
- })
- await wrapper.events.click(wrapper.getByIconName('mobile-puzzle'))
- expect(wrapper.emitted().click).toHaveLength(1)
- })
- it('provides a label for assistive technologies', async () => {
- const wrapper = renderComponent(CommonIcon, {
- props: { name: 'mobile-logo' },
- })
- expect(wrapper.getByIconName('mobile-logo')).toHaveAccessibleName(
- 'mobile-logo',
- )
- await wrapper.rerender({
- label: 'Product Logo',
- })
- expect(wrapper.getByIconName('mobile-logo')).toHaveAccessibleName(
- 'Product Logo',
- )
- })
- })
|