toHaveImagePreview.ts 617 B

1234567891011121314151617181920212223
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { getTestState } from '../utils.ts'
  3. export default function toHaveImagePreview(
  4. this: any,
  5. received: unknown,
  6. content: string,
  7. ) {
  8. const state = getTestState()
  9. const currentContent =
  10. state.imageViewerOptions &&
  11. state.imageViewerOptions.value.images[state.imageViewerOptions.value.index]
  12. .src
  13. const pass = currentContent === content
  14. return {
  15. pass,
  16. message: () =>
  17. `expected current image preview${
  18. this.isNot ? ' not' : ''
  19. } to be ${content}, but got ${currentContent}`,
  20. }
  21. }