CommonTicketLabel.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { renderComponent } from '#tests/support/components/index.ts'
  3. import { createDummyTicket } from '#shared/entities/ticket-article/__tests__/mocks/ticket.ts'
  4. import { EnumTicketStateColorCode } from '#shared/graphql/types.ts'
  5. import CommonTicketLabel from '#desktop/components/CommonTicketLabel/CommonTicketLabel.vue'
  6. describe('CommonTicketLabel', () => {
  7. it('display unauthorized state if unauthorized prop is true', () => {
  8. const wrapper = renderComponent(CommonTicketLabel, {
  9. props: {
  10. unauthorized: true,
  11. ticket: null,
  12. },
  13. router: true,
  14. })
  15. expect(wrapper.getByText('Access denied')).toBeInTheDocument()
  16. expect(wrapper.getByIconName('x-lg')).toBeInTheDocument()
  17. })
  18. it.each([
  19. EnumTicketStateColorCode.Open,
  20. EnumTicketStateColorCode.Closed,
  21. EnumTicketStateColorCode.Pending,
  22. EnumTicketStateColorCode.Escalating,
  23. ])('shows label in %s', (colorState) => {
  24. const wrapper = renderComponent(CommonTicketLabel, {
  25. props: {
  26. unauthorized: false,
  27. ticket: createDummyTicket({
  28. title: 'Foo test title',
  29. colorCode: colorState,
  30. }),
  31. },
  32. router: true,
  33. })
  34. expect(wrapper.getByText('Foo test title')).toBeInTheDocument()
  35. })
  36. })