testing.d.ts 3.2 KB

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