useOnlineNotificationSeen.spec.ts 832 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { ref } from 'vue'
  3. import { mockOnlineNotificationSeenGql } from '#shared/composables/__tests__/mocks/online-notification.ts'
  4. import type { ObjectWithId } from '#shared/types/utils.ts'
  5. import { waitUntil } from '#tests/support/utils.ts'
  6. import { useOnlineNotificationSeen } from '../useOnlineNotificationSeen.ts'
  7. describe('useOnlineNotificationSeen', () => {
  8. it('calls mutation when object changes', async () => {
  9. const mockSeen = mockOnlineNotificationSeenGql()
  10. const object = ref<ObjectWithId | undefined>(undefined)
  11. useOnlineNotificationSeen(object)
  12. object.value = { id: '2' }
  13. await waitUntil(() => mockSeen.calls.resolve)
  14. expect(mockSeen.spies.resolve).toHaveBeenCalledWith({
  15. objectId: '2',
  16. })
  17. })
  18. })