CommonLabel.spec.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. })