blob: e20d500282e7f1d40b89fed5fc52db9eab096edc [file] [log] [blame]
{"version":3,"file":"testing.js","sources":["../../../packages/router/esm5/testing/src/router_testing_module.js","../../../packages/router/esm5/testing/src/testing.js","../../../packages/router/esm5/testing/public_api.js","../../../packages/router/esm5/testing/testing.js"],"sourcesContent":["/**\n * @fileoverview added by tsickle\n * @suppress {checkTypes} checked by tsc\n */\n/**\n * @license\n * Copyright Google Inc. 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 */\nimport { Location, LocationStrategy } from '@angular/common';\nimport { MockLocationStrategy, SpyLocation } from '@angular/common/testing';\nimport { Compiler, Injectable, Injector, NgModule, NgModuleFactoryLoader, Optional } from '@angular/core';\nimport { ChildrenOutletContexts, NoPreloading, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTES, Router, RouterModule, UrlHandlingStrategy, UrlSerializer, provideRoutes, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS, ɵflatten as flatten } from '@angular/router';\n/**\n * \\@whatItDoes Allows to simulate the loading of ng modules in tests.\n *\n * \\@howToUse\n *\n * ```\n * const loader = TestBed.get(NgModuleFactoryLoader);\n *\n * \\@Component({template: 'lazy-loaded'})\n * class LazyLoadedComponent {}\n * \\@NgModule({\n * declarations: [LazyLoadedComponent],\n * imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]\n * })\n *\n * class LoadedModule {}\n *\n * // sets up stubbedModules\n * loader.stubbedModules = {lazyModule: LoadedModule};\n *\n * router.resetConfig([\n * {path: 'lazy', loadChildren: 'lazyModule'},\n * ]);\n *\n * router.navigateByUrl('/lazy/loaded');\n * ```\n *\n * \\@stable\n */\nvar SpyNgModuleFactoryLoader = /** @class */ (function () {\n function SpyNgModuleFactoryLoader(compiler) {\n this.compiler = compiler;\n /**\n * \\@docsNotRequired\n */\n this._stubbedModules = {};\n }\n Object.defineProperty(SpyNgModuleFactoryLoader.prototype, \"stubbedModules\", {\n /**\n * @docsNotRequired\n */\n get: /**\n * \\@docsNotRequired\n * @return {?}\n */\n function () { return this._stubbedModules; },\n /**\n * @docsNotRequired\n */\n set: /**\n * \\@docsNotRequired\n * @param {?} modules\n * @return {?}\n */\n function (modules) {\n var /** @type {?} */ res = {};\n for (var _i = 0, _a = Object.keys(modules); _i < _a.length; _i++) {\n var t = _a[_i];\n res[t] = this.compiler.compileModuleAsync(modules[t]);\n }\n this._stubbedModules = res;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * @param {?} path\n * @return {?}\n */\n SpyNgModuleFactoryLoader.prototype.load = /**\n * @param {?} path\n * @return {?}\n */\n function (path) {\n if (this._stubbedModules[path]) {\n return this._stubbedModules[path];\n }\n else {\n return /** @type {?} */ (Promise.reject(new Error(\"Cannot find module \" + path)));\n }\n };\n SpyNgModuleFactoryLoader.decorators = [\n { type: Injectable },\n ];\n /** @nocollapse */\n SpyNgModuleFactoryLoader.ctorParameters = function () { return [\n { type: Compiler, },\n ]; };\n return SpyNgModuleFactoryLoader;\n}());\nexport { SpyNgModuleFactoryLoader };\nfunction SpyNgModuleFactoryLoader_tsickle_Closure_declarations() {\n /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */\n SpyNgModuleFactoryLoader.decorators;\n /**\n * @nocollapse\n * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>}\n */\n SpyNgModuleFactoryLoader.ctorParameters;\n /**\n * \\@docsNotRequired\n * @type {?}\n */\n SpyNgModuleFactoryLoader.prototype._stubbedModules;\n /** @type {?} */\n SpyNgModuleFactoryLoader.prototype.compiler;\n}\n/**\n * @param {?} opts\n * @return {?}\n */\nfunction isUrlHandlingStrategy(opts) {\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/**\n * Router setup factory function used for testing.\n *\n * \\@stable\n * @param {?} urlSerializer\n * @param {?} contexts\n * @param {?} location\n * @param {?} loader\n * @param {?} compiler\n * @param {?} injector\n * @param {?} routes\n * @param {?=} opts\n * @param {?=} urlHandlingStrategy\n * @return {?}\n */\nexport function setupTestingRouter(urlSerializer, contexts, location, loader, compiler, injector, routes, opts, urlHandlingStrategy) {\n var /** @type {?} */ router = new Router(/** @type {?} */ ((null)), urlSerializer, contexts, location, injector, loader, compiler, flatten(routes));\n // Handle deprecated argument ordering.\n if (opts) {\n if (isUrlHandlingStrategy(opts)) {\n router.urlHandlingStrategy = opts;\n }\n else if (opts.paramsInheritanceStrategy) {\n router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;\n }\n }\n if (urlHandlingStrategy) {\n router.urlHandlingStrategy = urlHandlingStrategy;\n }\n return router;\n}\n/**\n * \\@whatItDoes Sets up the router to be used for testing.\n *\n * \\@howToUse\n *\n * ```\n * beforeEach(() => {\n * TestBed.configureTestModule({\n * imports: [\n * RouterTestingModule.withRoutes(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}])]\n * )\n * ]\n * });\n * });\n * ```\n *\n * \\@description\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of {\\@link Location}, {\\@link LocationStrategy}, and {\\@link\n * NgModuleFactoryLoader}.\n *\n * \\@stable\n */\nvar RouterTestingModule = /** @class */ (function () {\n function RouterTestingModule() {\n }\n /**\n * @param {?} routes\n * @param {?=} config\n * @return {?}\n */\n RouterTestingModule.withRoutes = /**\n * @param {?} routes\n * @param {?=} config\n * @return {?}\n */\n function (routes, config) {\n return {\n ngModule: RouterTestingModule,\n providers: [\n provideRoutes(routes),\n { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },\n ]\n };\n };\n RouterTestingModule.decorators = [\n { type: NgModule, args: [{\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS, { provide: Location, useClass: SpyLocation },\n { provide: LocationStrategy, useClass: MockLocationStrategy },\n { provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader }, {\n provide: Router,\n useFactory: setupTestingRouter,\n deps: [\n UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,\n ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()]\n ]\n },\n { provide: PreloadingStrategy, useExisting: NoPreloading }, provideRoutes([])\n ]\n },] },\n ];\n /** @nocollapse */\n RouterTestingModule.ctorParameters = function () { return []; };\n return RouterTestingModule;\n}());\nexport { RouterTestingModule };\nfunction RouterTestingModule_tsickle_Closure_declarations() {\n /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */\n RouterTestingModule.decorators;\n /**\n * @nocollapse\n * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>}\n */\n RouterTestingModule.ctorParameters;\n}\n//# sourceMappingURL=router_testing_module.js.map","/**\n * @fileoverview added by tsickle\n * @suppress {checkTypes} checked by tsc\n */\n/**\n * @license\n * Copyright Google Inc. 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/**\n * @module\n * @description\n * Entry point for all public APIs of the router/testing package.\n */\nexport { SpyNgModuleFactoryLoader, setupTestingRouter, RouterTestingModule } from './router_testing_module';\n//# sourceMappingURL=testing.js.map","/**\n * @fileoverview added by tsickle\n * @suppress {checkTypes} checked by tsc\n */\n/**\n * @license\n * Copyright Google Inc. 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/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport { SpyNgModuleFactoryLoader, setupTestingRouter, RouterTestingModule } from './src/testing';\n// This file only reexports content of the `src` folder. Keep it that way.\n//# sourceMappingURL=public_api.js.map","/**\n * @fileoverview added by tsickle\n * @suppress {checkTypes} checked by tsc\n */\n/**\n * Generated bundle index. Do not edit.\n */\nexport { SpyNgModuleFactoryLoader, setupTestingRouter, RouterTestingModule } from './public_api';\n//# sourceMappingURL=testing.js.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