router_testing_module.d.ts
2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Location } from '@angular/common';
import { Compiler, Injector, ModuleWithProviders, NgModuleFactory, NgModuleFactoryLoader } from '@angular/core';
import { Route, Router, RouterOutletMap, Routes, UrlHandlingStrategy, UrlSerializer } from '@angular/router';
/**
* @whatItDoes Allows to simulate the loading of ng modules in tests.
*
* @howToUse
*
* ```
* const loader = TestBed.get(NgModuleFactoryLoader);
*
* @Component({template: 'lazy-loaded'})
* class LazyLoadedComponent {}
* @NgModule({
* declarations: [LazyLoadedComponent],
* imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
* })
*
* class LoadedModule {}
*
* // sets up stubbedModules
* loader.stubbedModules = {lazyModule: LoadedModule};
*
* router.resetConfig([
* {path: 'lazy', loadChildren: 'lazyModule'},
* ]);
*
* router.navigateByUrl('/lazy/loaded');
* ```
*
* @stable
*/
export declare class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {
private compiler;
/**
* @docsNotRequired
*/
private _stubbedModules;
/**
* @docsNotRequired
*/
/**
* @docsNotRequired
*/
stubbedModules: {
[path: string]: any;
};
constructor(compiler: Compiler);
load(path: string): Promise<NgModuleFactory<any>>;
}
/**
* Router setup factory function used for testing.
*
* @stable
*/
export declare function setupTestingRouter(urlSerializer: UrlSerializer, outletMap: RouterOutletMap, location: Location, loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][], urlHandlingStrategy?: UrlHandlingStrategy): Router;
/**
* @whatItDoes Sets up the router to be used for testing.
*
* @howToUse
*
* ```
* beforeEach(() => {
* TestBed.configureTestModule({
* imports: [
* RouterTestingModule.withRoutes(
* [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}])]
* )
* ]
* });
* });
* ```
*
* @description
*
* The modules sets up the router to be used for testing.
* It provides spy implementations of {@link Location}, {@link LocationStrategy}, and {@link
* NgModuleFactoryLoader}.
*
* @stable
*/
export declare class RouterTestingModule {
static withRoutes(routes: Routes): ModuleWithProviders;
}