123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { renderComponent } from '#tests/support/components/index.ts'
- import CommonBreadcrumb from '../CommonBreadcrumb.vue'
- describe('breadcrumb', () => {
- it('renders the breadcrumb', async () => {
- const view = renderComponent(CommonBreadcrumb, {
- props: {
- items: [
- {
- label: 'Dashboard',
- route: '/',
- },
- {
- label: 'Settings',
- },
- ],
- },
- slots: {
- trailing: 'trailing slot',
- },
- router: true,
- })
- const link = view.getByRole('link')
- expect(link).toHaveTextContent('Dashboard')
- expect(link).toHaveAttribute('href', '/desktop/')
- expect(view.getByText('Settings')).toBeInTheDocument()
- expect(view.getByText('trailing slot')).toBeInTheDocument()
- })
- it('renders icons', async () => {
- const view = renderComponent(CommonBreadcrumb, {
- props: {
- items: [
- {
- label: 'Dashboard',
- route: '/',
- icon: 'eye',
- },
- {
- label: 'Settings',
- },
- ],
- },
- router: true,
- })
- const icon = view.getByIconName('eye')
- expect(icon).toBeInTheDocument()
- })
- it('emphasizes the last item', async () => {
- const view = renderComponent(CommonBreadcrumb, {
- props: {
- items: [
- {
- label: 'Dashboard',
- route: '/',
- },
- {
- label: 'Settings',
- },
- ],
- emphasizeLastItem: true,
- },
- router: true,
- })
- const lastItem = view.getByText('Settings')
- expect(lastItem.parentElement).toHaveClass(
- 'last:dark:text-white last:text-black',
- )
- })
- it('supports different text sizes', async () => {
- const view = renderComponent(CommonBreadcrumb, {
- props: {
- items: [
- {
- label: 'Dashboard',
- route: '/',
- },
- {
- label: 'Settings',
- },
- ],
- },
- router: true,
- })
- // Default size
- expect(view.getByLabelText('Breadcrumb navigation')).toHaveClass(
- 'text-base',
- )
- await view.rerender({
- items: [
- {
- label: 'Dashboard',
- route: '/',
- },
- {
- label: 'Settings',
- },
- ],
- size: 'small',
- })
- expect(view.getByLabelText('Breadcrumb navigation')).toHaveClass('text-xs')
- })
- it('support trailing slot', async () => {
- const view = renderComponent(CommonBreadcrumb, {
- props: {
- items: [
- {
- label: 'Dashboard',
- route: '/',
- },
- {
- label: 'Settings',
- },
- ],
- },
- slots: {
- trailing: 'trailing slot',
- },
- router: true,
- })
- expect(view.getByText('trailing slot')).toBeInTheDocument()
- })
- })
|