angular-cn/aio/dist/generated/docs/api/router/testing/RouterTestingModule.json

5 lines
32 KiB
JSON

{
"id": "api/router/testing/RouterTestingModule",
"title": "RouterTestingModule",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/router\", \"name\": \"@angular/router\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/router/testing\", \"name\": \"@angular/router/testing\" } },\n { \"@type\": \"ListItem\", \"position\": 4, \"item\": { \"@id\": \"https://angular.io/api/router/testing/RouterTestingModule\", \"name\": \"RouterTestingModule\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/router\">@angular/router</a> > <a href=\"api/router/testing\">@angular/router/testing</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/router/testing/src/router_testing_module.ts?message=docs(router)%3A%20describe%20your%20change...#L136-L190\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/testing/src/router_testing_module.ts#L136-L190\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"routertestingmodule\">RouterTestingModule<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#routertestingmodule\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label ngmodule\">ngmodule</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Sets up the router to be used for testing.</p>\n\n <p><a href=\"api/router/testing/RouterTestingModule#description\">See more...</a></p>\n </section>\n \n \n \n <section class=\"ngmodule-overview\">\n<code-example language=\"ts\" hidecopy=\"true\">\nclass <a href=\"api/router/testing/RouterTestingModule\" class=\"code-anchor\">RouterTestingModule</a> {\n <a class=\"code-anchor\" href=\"api/router/testing/RouterTestingModule#withRoutes\">static <span class=\"member-name\">withRoutes</span>(routes: Routes, config?: ExtraOptions): ModuleWithProviders&#x3C;RouterTestingModule></a>\n}\n</code-example>\n\n \n \n\n</section>\n\n\n \n\n \n \n \n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>The modules sets up the router to be used for testing.\nIt provides spy implementations of <code><a href=\"api/common/Location\" class=\"code-anchor\">Location</a></code>, <code><a href=\"api/common/LocationStrategy\" class=\"code-anchor\">LocationStrategy</a></code>, and <a href=\"api/core/NgModuleFactoryLoader\"><code>NgModuleFactoryLoader</code></a>.</p>\n\n <p>Further information available in the <a href=\"api/router/testing/RouterTestingModule#usage-notes\">Usage Notes</a>...</p>\n</section>\n\n \n\n \n\n<section class=\"static-methods\">\n <h2 id=\"static-methods\">Static methods<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#static-methods\"><i class=\"material-icons\">link</i></a></h2>\n \n <a id=\"withRoutes\"></a>\n<table class=\"is-full-width method-table static-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"withroutes\">\n withRoutes()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#withroutes\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/router/testing/src/router_testing_module.ts?message=docs(router)%3A%20describe%20your%20change...#L180-L189\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/testing/src/router_testing_module.ts#L180-L189\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n \n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><a href=\"api/upgrade/static\" class=\"code-anchor\">static</a> <span class=\"member-name\">withRoutes</span>(routes: Routes, config?: ExtraOptions): ModuleWithProviders&#x3C;RouterTestingModule></code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table static-method-overload-parameters\">\n <tbody>\n \n <tr class=\"static-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>routes</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/router/Routes\" class=\"code-anchor\">Routes</a></code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n <tr class=\"static-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>config</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/router/ExtraOptions\" class=\"code-anchor\">ExtraOptions</a></code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns\">Returns</h6>\n <p><code><a href=\"api/core/ModuleWithProviders\" class=\"code-anchor\">ModuleWithProviders</a>&#x3C;<a href=\"api/router/testing/RouterTestingModule\" class=\"code-anchor\">RouterTestingModule</a>></code></p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n</section>\n\n \n\n \n\n\n \n\n\n \n \n<section class=\"providers\">\n <h2 id=\"providers\">Providers<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#providers\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table property-table\">\n <thead>\n <tr>\n <th>Provider</th>\n </tr>\n </thead>\n <tbody>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n ROUTER_PROVIDERS\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n { provide: <a href=\"api/common/Location\" class=\"code-anchor\">Location</a>, useClass: <a href=\"api/common/testing/SpyLocation\" class=\"code-anchor\">SpyLocation</a> }\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n { provide: <a href=\"api/common/LocationStrategy\" class=\"code-anchor\">LocationStrategy</a>, useClass: <a href=\"api/common/testing/MockLocationStrategy\" class=\"code-anchor\">MockLocationStrategy</a> }\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n { provide: <a href=\"api/core/NgModuleFactoryLoader\" class=\"code-anchor\">NgModuleFactoryLoader</a>, useClass: <a href=\"api/router/testing/SpyNgModuleFactoryLoader\" class=\"code-anchor\">SpyNgModuleFactoryLoader</a> }\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n {\n provide: <a href=\"api/router/Router\" class=\"code-anchor\">Router</a>,\n useFactory: <a href=\"api/router/testing/setupTestingRouter\" class=\"code-anchor\">setupTestingRouter</a>,\n deps: [\n <a href=\"api/router/UrlSerializer\" class=\"code-anchor\">UrlSerializer</a>, <a href=\"api/router/ChildrenOutletContexts\" class=\"code-anchor\">ChildrenOutletContexts</a>, <a href=\"api/common/Location\" class=\"code-anchor\">Location</a>, <a href=\"api/core/NgModuleFactoryLoader\" class=\"code-anchor\">NgModuleFactoryLoader</a>, <a href=\"api/core/Compiler\" class=\"code-anchor\">Compiler</a>, <a href=\"api/core/Injector\" class=\"code-anchor\">Injector</a>,\n <a href=\"api/router/ROUTES\" class=\"code-anchor\">ROUTES</a>, <a href=\"api/router/ROUTER_CONFIGURATION\" class=\"code-anchor\">ROUTER_CONFIGURATION</a>, [<a href=\"api/router/UrlHandlingStrategy\" class=\"code-anchor\">UrlHandlingStrategy</a>, new <a href=\"api/core/Optional\" class=\"code-anchor\">Optional</a>()]\n ]\n}\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n { provide: <a href=\"api/router/PreloadingStrategy\" class=\"code-anchor\">PreloadingStrategy</a>, useExisting: <a href=\"api/router/NoPreloading\" class=\"code-anchor\">NoPreloading</a> }\n </code-example>\n </td>\n </tr>\n \n <tr>\n <td>\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">\n <a href=\"api/router/provideRoutes\" class=\"code-anchor\">provideRoutes</a>([])\n </code-example>\n </td>\n </tr>\n \n </tbody>\n </table>\n </section>\n\n \n\n \n \n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <h3 id=\"example\">Example<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/RouterTestingModule#example\"><i class=\"material-icons\">link</i></a></h3>\n<code-example>\nbeforeEach(() => {\n TestBed.configureTestingModule({\n imports: [\n RouterTestingModule.withRoutes(\n [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n )\n ]\n });\n});\n</code-example>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/router/testing\n - guide/testing-components-scenarios\n-->\n<!-- links from this doc:\n - /api\n - api/common/Location\n - api/common/LocationStrategy\n - api/common/testing/MockLocationStrategy\n - api/common/testing/SpyLocation\n - api/core/Compiler\n - api/core/Injector\n - api/core/ModuleWithProviders\n - api/core/NgModuleFactoryLoader\n - api/core/Optional\n - api/router\n - api/router/ChildrenOutletContexts\n - api/router/ExtraOptions\n - api/router/NoPreloading\n - api/router/PreloadingStrategy\n - api/router/ROUTER_CONFIGURATION\n - api/router/ROUTES\n - api/router/Router\n - api/router/Routes\n - api/router/UrlHandlingStrategy\n - api/router/UrlSerializer\n - api/router/provideRoutes\n - api/router/testing\n - api/router/testing/RouterTestingModule#description\n - api/router/testing/RouterTestingModule#example\n - api/router/testing/RouterTestingModule#providers\n - api/router/testing/RouterTestingModule#routertestingmodule\n - api/router/testing/RouterTestingModule#static-methods\n - api/router/testing/RouterTestingModule#usage-notes\n - api/router/testing/RouterTestingModule#withRoutes\n - api/router/testing/RouterTestingModule#withroutes\n - api/router/testing/SpyNgModuleFactoryLoader\n - api/router/testing/setupTestingRouter\n - api/upgrade/static\n - https://github.com/angular/angular/edit/master/packages/router/testing/src/router_testing_module.ts?message=docs(router)%3A%20describe%20your%20change...#L136-L190\n - https://github.com/angular/angular/edit/master/packages/router/testing/src/router_testing_module.ts?message=docs(router)%3A%20describe%20your%20change...#L180-L189\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/testing/src/router_testing_module.ts#L136-L190\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/testing/src/router_testing_module.ts#L180-L189\n-->"
}