UNPKG

3.49 kBTypeScriptView Raw
1/**
2 * @license Angular v10.0.9
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { ChildrenOutletContexts } from '@angular/router';
8import { Compiler } from '@angular/core';
9import { ExtraOptions } from '@angular/router';
10import { Injector } from '@angular/core';
11import { Location } from '@angular/common';
12import { ModuleWithProviders } from '@angular/core';
13import { NgModuleFactory } from '@angular/core';
14import { NgModuleFactoryLoader } from '@angular/core';
15import { Route } from '@angular/router';
16import { Router } from '@angular/router';
17import { Routes } from '@angular/router';
18import { UrlHandlingStrategy } from '@angular/router';
19import { UrlSerializer } from '@angular/router';
20
21/**
22 * @description
23 *
24 * Sets up the router to be used for testing.
25 *
26 * The modules sets up the router to be used for testing.
27 * It provides spy implementations of `Location`, `LocationStrategy`, and {@link
28 * NgModuleFactoryLoader}.
29 *
30 * @usageNotes
31 * ### Example
32 *
33 * ```
34 * beforeEach(() => {
35 * TestBed.configureTestingModule({
36 * imports: [
37 * RouterTestingModule.withRoutes(
38 * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]
39 * )
40 * ]
41 * });
42 * });
43 * ```
44 *
45 * @publicApi
46 */
47export declare class RouterTestingModule {
48 static withRoutes(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterTestingModule>;
49}
50
51/**
52 * Router setup factory function used for testing.
53 *
54 * @publicApi
55 */
56export declare function setupTestingRouter(urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location, loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][], opts?: ExtraOptions, urlHandlingStrategy?: UrlHandlingStrategy): Router;
57
58/**
59 * Router setup factory function used for testing.
60 *
61 * @deprecated As of v5.2. The 2nd-to-last argument should be `ExtraOptions`, not
62 * `UrlHandlingStrategy`
63 * @publicApi
64 */
65export declare function setupTestingRouter(urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location, loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][], urlHandlingStrategy?: UrlHandlingStrategy): Router;
66
67/**
68 * @description
69 *
70 * Allows to simulate the loading of ng modules in tests.
71 *
72 * ```
73 * const loader = TestBed.inject(NgModuleFactoryLoader);
74 *
75 * @Component({template: 'lazy-loaded'})
76 * class LazyLoadedComponent {}
77 * @NgModule({
78 * declarations: [LazyLoadedComponent],
79 * imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
80 * })
81 *
82 * class LoadedModule {}
83 *
84 * // sets up stubbedModules
85 * loader.stubbedModules = {lazyModule: LoadedModule};
86 *
87 * router.resetConfig([
88 * {path: 'lazy', loadChildren: 'lazyModule'},
89 * ]);
90 *
91 * router.navigateByUrl('/lazy/loaded');
92 * ```
93 *
94 * @publicApi
95 */
96export declare class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {
97 private compiler;
98 /**
99 * @docsNotRequired
100 */
101 private _stubbedModules;
102 /**
103 * @docsNotRequired
104 */
105 set stubbedModules(modules: {
106 [path: string]: any;
107 });
108 /**
109 * @docsNotRequired
110 */
111 get stubbedModules(): {
112 [path: string]: any;
113 };
114 constructor(compiler: Compiler);
115 load(path: string): Promise<NgModuleFactory<any>>;
116}
117
118export { }