mock-mediaTheme.ts 563 B

12345678910111213141516171819
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { EnumAppearanceTheme } from '#shared/graphql/types.ts'
  3. export const addEventListener = vi.fn()
  4. export const mockMediaTheme = (theme: EnumAppearanceTheme) => {
  5. window.matchMedia = (rule) =>
  6. ({
  7. matches: rule === '(prefers-color-scheme: dark)' && theme === 'dark',
  8. addEventListener,
  9. }) as any
  10. window.matchMedia = (rule) =>
  11. ({
  12. matches: rule === '(prefers-color-scheme: light)' && theme === 'light',
  13. addEventListener,
  14. }) as any
  15. }