1 line
19 KiB
Plaintext
1 line
19 KiB
Plaintext
|
{"version":3,"file":"testing.mjs","sources":["../../../../../../packages/router/testing/src/router_testing_module.ts","../../../../../../packages/router/testing/src/router_testing_harness.ts","../../../../../../packages/router/testing/src/testing.ts","../../../../../../packages/router/testing/public_api.ts","../../../../../../packages/router/testing/index.ts","../../../../../../packages/router/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location} from '@angular/common';\nimport {provideLocationMocks} from '@angular/common/testing';\nimport {Compiler, inject, Injector, ModuleWithProviders, NgModule} from '@angular/core';\nimport {ChildrenOutletContexts, ExtraOptions, NoPreloading, Route, Router, ROUTER_CONFIGURATION, RouteReuseStrategy, RouterModule, ROUTES, Routes, TitleStrategy, UrlHandlingStrategy, UrlSerializer, withPreloading, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS} from '@angular/router';\n\nfunction isUrlHandlingStrategy(opts: ExtraOptions|\n UrlHandlingStrategy): opts is UrlHandlingStrategy {\n // This property check is needed because UrlHandlingStrategy is an interface and doesn't exist at\n // runtime.\n return 'shouldProcessUrl' in opts;\n}\n\nfunction throwInvalidConfigError(parameter: string): never {\n throw new Error(\n `Parameter ${parameter} does not match the one available in the injector. ` +\n '`setupTestingRouter` is meant to be used as a factory function with dependencies coming from DI.');\n}\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n * @deprecated Use `provideRouter` or `RouterModule` instead.\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions|UrlHandlingStrategy|null, urlHandlingStrategy?: UrlHandlingStrategy,\n routeReuseStrategy?: RouteReuseStrategy, titleStrategy?: TitleStrategy) {\n // Note: The checks below are to detect misconfigured providers and invalid uses of\n // `setupTestingRouter`. This function is not used internally (neither in router code or anywhere\n // in g3). It appears this function was exposed as publicApi by mistake and should not be used\n // externally either. However, if it is, the documented intent is to be used as a factory function\n // and parameter values should always match what's available in DI.\n if (urlSerializer !== inject(UrlSerializer)) {\n throwInvalidConfigError('urlSerializer');\n }\n if (contexts !== inject(ChildrenOutletContexts)) {\n throwInvalidConfigError('contexts');\n }\n if (location !== inject(Location)) {\n throwInvalidConfigError('location');\n }\n if (compiler !== inject(Compiler)) {\n throwInvalidConfigError('compiler');\n }\n if (injector !== inject(Injector)) {\n throwInvalidConfigError('injector');\n }\n if (routes !== inject(ROUTES)) {\n throwInvalidConfigError('routes');\n }\n if (opts) {\n // Handle deprecated argument ordering.\n if (isUrlHandlingStrategy(opts)) {\n if (opts !== inject(UrlHandlingStrategy)) {\n throwInvalidConfigError('opts (UrlHandlingStrategy)');\n }\n } else {\n if (opts !== inject(ROUTER_CONFIGURATION)) {\n throwInvalidConfigError('opts (ROUTER_CONFIGURATION)');\n }\n }\n }\n\n if (urlHandlingStrategy !== inject(UrlHandlingStrategy)) {\n throwInvalidConfigError('urlHandlingStrategy');\n }\n\n if (routeReuseStrategy !== inject(RouteReuseStrategy)) {\n throwInvalidConfigError('routeReuseStrategy');\n }\n\n if (titleStrategy !== inject(TitleStrategy)) {\n throwInvalidConfigError('titleStrategy');\n }\n\n return new Router();\n}\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testin
|