CommonBadge.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { renderComponent } from '#tests/support/components/index.ts'
  3. import CommonBadge from '../CommonBadge.vue'
  4. describe('CommonLabel.vue', () => {
  5. it('renders when no props are passed', () => {
  6. const view = renderComponent(CommonBadge, {
  7. slots: {
  8. default: 'Dummy',
  9. },
  10. })
  11. const badge = view.getByTestId('common-badge')
  12. expect(badge).toHaveTextContent('Dummy')
  13. expect(badge).toHaveClass('text-xs')
  14. })
  15. it('renders bigger text if size is given', () => {
  16. const view = renderComponent(CommonBadge, {
  17. props: {
  18. size: 'large',
  19. },
  20. slots: {
  21. default: 'Dummy',
  22. },
  23. })
  24. const badge = view.getByTestId('common-badge')
  25. expect(badge).toHaveTextContent('Dummy')
  26. expect(badge).toHaveClass('text-base')
  27. })
  28. it('renders correct colors if variant is given', () => {
  29. const view = renderComponent(CommonBadge, {
  30. props: {
  31. variant: 'success',
  32. },
  33. slots: {
  34. default: 'Dummy',
  35. },
  36. })
  37. const badge = view.getByTestId('common-badge')
  38. expect(badge).toHaveTextContent('Dummy')
  39. expect(badge).toHaveClasses([
  40. 'common-badge',
  41. 'common-badge-success',
  42. 'text-xs',
  43. ])
  44. })
  45. it('renders correct colors if variant custom is given', () => {
  46. const view = renderComponent(CommonBadge, {
  47. props: {
  48. variant: 'custom',
  49. class: ['dark:bg-pink-300', 'bg-pink-300', 'text-white'],
  50. },
  51. slots: {
  52. default: 'Dummy',
  53. },
  54. })
  55. const badge = view.getByTestId('common-badge')
  56. expect(badge).toHaveTextContent('Dummy')
  57. expect(badge).toHaveClasses([
  58. 'text-xs',
  59. 'dark:bg-pink-300',
  60. 'bg-pink-300',
  61. 'text-white',
  62. ])
  63. })
  64. })