OrganizationItem.spec.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. const now = new Date(2022, 1, 1, 20, 0, 0, 0)
  3. vi.setSystemTime(now)
  4. import { renderComponent } from '@tests/support/components'
  5. import type { OrganizationItemData } from '../types'
  6. import OrganizationItem from '../OrganizationItem.vue'
  7. describe('ticket item display', () => {
  8. afterEach(() => {
  9. vi.useRealTimers()
  10. })
  11. it('renders correctly', () => {
  12. const now = new Date(2022, 1, 1)
  13. vi.setSystemTime(now)
  14. const organization: OrganizationItemData = {
  15. id: '54321',
  16. ticketsCount: {
  17. open: 2,
  18. closed: 1,
  19. },
  20. internalId: 3,
  21. name: 'lorem ipsum',
  22. active: true,
  23. members: {
  24. edges: [
  25. {
  26. node: { fullname: 'Erik Wise' },
  27. },
  28. {
  29. node: { fullname: 'Peter Smith' },
  30. },
  31. ],
  32. totalCount: 3,
  33. },
  34. updatedAt: new Date(2022, 1, 1, 10, 0, 0, 0).toISOString(),
  35. updatedBy: {
  36. id: '456',
  37. fullname: 'Jane Doe',
  38. },
  39. }
  40. const view = renderComponent(OrganizationItem, {
  41. props: {
  42. entity: organization,
  43. },
  44. store: true,
  45. })
  46. expect(view.getByText('lorem ipsum')).toBeInTheDocument()
  47. expect(view.getByText(/2 tickets/)).toBeInTheDocument()
  48. expect(view.getByText(/·/)).toBeInTheDocument()
  49. expect(view.getByText(/Erik Wise, Peter Smith, \+1/)).toBeInTheDocument()
  50. expect(
  51. view.getByText('edited 10 hours ago by Jane Doe'),
  52. ).toBeInTheDocument()
  53. })
  54. it('renders when something is missing', () => {
  55. const organization: OrganizationItemData = {
  56. id: '54321',
  57. internalId: 2,
  58. ticketsCount: {
  59. open: 1,
  60. closed: 0,
  61. },
  62. name: 'lorem ipsum',
  63. active: true,
  64. }
  65. const view = renderComponent(OrganizationItem, {
  66. props: {
  67. entity: organization,
  68. },
  69. store: true,
  70. })
  71. expect(view.getByText('lorem ipsum')).toBeInTheDocument()
  72. expect(view.getByText(/1 ticket/)).toBeInTheDocument()
  73. expect(view.queryByText(/·/)).not.toBeInTheDocument()
  74. expect(view.queryByTestId('stringUpdated')).not.toBeInTheDocument()
  75. })
  76. })