/** * Module that allows client-side code to use browser globals (such as `document` or `Node`) in a * way that allows those globals to be replaced by mocks in browser-less tests. * * import {G} from 'browserGlobals'; * ... use G.document * ... use G.Node * * Initially, the global `window` object, is the source of the global values. * * To use a mock of globals in a test, use: * * import {pushGlobals, popGlobals} as G from 'browserGlobals'; * before(function() { * pushGlobals(mockWindow); // e.g. jsdom.jsdom(...).defaultView * }); * after(function() { * popGlobals(); * }); */ export interface IBrowserGlobals { DocumentFragment: typeof DocumentFragment; Element: typeof Element; Node: typeof Node; document: typeof document; window: typeof window; } export interface IBrowserGlobalsLax extends IBrowserGlobals { window: any; } export declare const G: IBrowserGlobals; /** * Replace globals with those from the given object. Use popGlobals() to restore previous values. */ export declare function pushGlobals(globals: IBrowserGlobalsLax): void; /** * Restore the values of globals to undo the preceding pushGlobals() call. */ export declare function popGlobals(): void;