import "@testing-library/jest-dom";

// Guard for node-environment test files (e.g. pure-logic units that opt out of
// jsdom via `// @vitest-environment node`). `window` is undefined there.
if (typeof window !== "undefined") {
  Object.defineProperty(window, "matchMedia", {
    writable: true,
    value: (query: string) => ({
      matches: false,
      media: query,
      onchange: null,
      addListener: () => {},
      removeListener: () => {},
      addEventListener: () => {},
      removeEventListener: () => {},
      dispatchEvent: () => {},
    }),
  });
}
