mock-match-media
Version:
mock window.matchMedia for tests or node
20 lines (19 loc) • 762 B
TypeScript
import { Environment } from "media-query-fns";
//#region src/index.d.ts
type MediaState = { [key in keyof Environment as key extends `${infer Key}Px` ? Key : key]?: Environment[key] };
declare const EventCompat: typeof Event;
declare const matchMedia: typeof window.matchMedia;
declare class MediaQueryListEvent extends EventCompat {
readonly media: string;
readonly matches: boolean;
constructor(type: "change", options?: {
media?: string;
matches?: boolean;
});
}
declare const setMedia: (media: MediaState) => void;
declare const cleanupListeners: () => void;
declare const cleanupMedia: () => void;
declare const cleanup: () => void;
//#endregion
export { MediaQueryListEvent, cleanup, cleanupListeners, cleanupMedia, matchMedia, setMedia };