useCheckBodyAttachmentReference.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useCheckBodyAttachmentReference } from '../useCheckBodyAttachmentReference.ts'
  3. describe('useCheckBodyAttachmentReference', () => {
  4. it('check for missing body attachment reference', () => {
  5. const { missingBodyAttachmentReference } = useCheckBodyAttachmentReference()
  6. expect(missingBodyAttachmentReference('I attached a file.')).toBeTruthy()
  7. })
  8. it('check for existing attachment and body reference', () => {
  9. const { missingBodyAttachmentReference } = useCheckBodyAttachmentReference()
  10. expect(
  11. missingBodyAttachmentReference('I attached a file.', [
  12. { id: '123', name: 'filename.png' },
  13. ]),
  14. ).toBeFalsy()
  15. })
  16. it('not attachment reference in body', () => {
  17. const { missingBodyAttachmentReference } = useCheckBodyAttachmentReference()
  18. expect(
  19. missingBodyAttachmentReference('I worked on the problem.'),
  20. ).toBeFalsy()
  21. })
  22. it('ignore attachment match words in quoted body parts', () => {
  23. const { missingBodyAttachmentReference } = useCheckBodyAttachmentReference()
  24. expect(
  25. missingBodyAttachmentReference(
  26. '<p>Yes I did already a first look.</p><blockquote type="cite" data-marker="signature-before"><p>I attached a file did you saw id?</p></blockquote>',
  27. ),
  28. ).toBeFalsy()
  29. })
  30. })