UNPKG

@bespunky/angular-zen

Version:

The Angular tools you always wished were there.

37 lines (36 loc) 1.62 kB
import { Router } from '@angular/router'; import { MockHeadElement } from '../mocks/head.mock'; /** * Configures a testing module provided with a ready-to-use mock for [`DOCUMENT`](/miscellaneous/variables.html#DOCUMENT). * * Any element created using `DocumentRef.nativeDocument.createElement()` will go through this mock. * If a script element was requested, a `MockScriptElement` object is returned. * If a link element was requested, the `MockLinkElement` object is returned. * If any other tag name is requested, a new `MockElement` object is returned. * * Used when testing head related services (e.g. HeadService, LazyLoaderService). * * Internally, this plants the following structure in [`DocumentRef`](/additional-documentation/coremodule/documentref.html): * * `DocumentRef.nativeDocument.head -> MockHeadElement` * * `DocumentRef.nativeDocument.createElement -> () => MockScriptElement | MockLinkElement | MockElement(<tagName>)` * * The returned mocks can be deconstructed like so: * @example * let mockHeadElement: MockHeadElement; * let mockDocument : any; * ({ mockHeadElement, mockDocument } = setupDocumentRefMock()); // mockDocument is also a jest.SpyInstance */ export declare function setupDocumentRefMock(): { mockHeadElement: MockHeadElement; mockDocument: any; }; /** * Wraps the `navigate` and `navigateByUrl` methods of the router with a call to `NgZone.run()`. * Fixes the warning when using the router in unit tests. * * @export * @param {Router} router The router instance. */ export declare function forceRoutingInsideAngularZone(router: Router): void;