CommonLabel.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { renderComponent } from '#tests/support/components/index.ts'
  3. import CommonLabel from '../CommonLabel.vue'
  4. describe('CommonLabel.vue', () => {
  5. it('renders when no props are passed', () => {
  6. const view = renderComponent(CommonLabel, {
  7. slots: {
  8. default: 'Dummy',
  9. },
  10. })
  11. const label = view.getByTestId('common-label')
  12. expect(label).toHaveTextContent('Dummy')
  13. expect(label).toHaveClass('text-sm')
  14. })
  15. it('renders bigger text if size is given', () => {
  16. const view = renderComponent(CommonLabel, {
  17. props: {
  18. size: 'large',
  19. },
  20. slots: {
  21. default: 'Dummy',
  22. },
  23. })
  24. const label = view.getByTestId('common-label')
  25. expect(label).toHaveTextContent('Dummy')
  26. expect(label).toHaveClass('text-base')
  27. })
  28. it('renders icons (prefix + suffix)', () => {
  29. const view = renderComponent(CommonLabel, {
  30. props: {
  31. prefixIcon: 'web',
  32. suffixIcon: 'web',
  33. },
  34. slots: {
  35. default: 'Dummy',
  36. },
  37. })
  38. const label = view.getByTestId('common-label')
  39. expect(label).toHaveTextContent('Dummy')
  40. expect(view.getAllByIconName('web')).toHaveLength(2)
  41. })
  42. })