headerTitle.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { createTestingPinia } from '@pinia/testing'
  3. import type { RouteLocationNormalized } from 'vue-router'
  4. import { nextTick } from 'vue'
  5. import useMetaTitle from '@shared/composables/useMetaTitle'
  6. import { useApplicationStore } from '@shared/stores/application'
  7. import headerTitle from '../headerTitle'
  8. describe('headerTitle', () => {
  9. createTestingPinia({ createSpy: vi.fn })
  10. useApplicationStore().config.product_name = 'Zammad'
  11. const from = {} as RouteLocationNormalized
  12. beforeEach(() => {
  13. useMetaTitle().initializeMetaTitle()
  14. })
  15. it('should change the header title from the route meta data', async () => {
  16. expect.assertions(2)
  17. const to = {
  18. name: 'TicketOverview',
  19. path: '/tickets',
  20. meta: {
  21. title: 'Ticket Overview',
  22. requiresAuth: true,
  23. },
  24. } as RouteLocationNormalized
  25. expect(document.title).toEqual('Zammad')
  26. headerTitle(to, from)
  27. await nextTick()
  28. expect(document.title).toEqual('Zammad - Ticket Overview')
  29. })
  30. })