projecte_ionic/node_modules/@angular/compiler/fesm2015/testing.js.map
2022-02-09 18:30:03 +01:00

1 line
17 KiB
Plaintext
Executable file

{"version":3,"file":"testing.js","sources":["../../../../../../packages/compiler/testing/src/resource_loader_mock.ts","../../../../../../packages/compiler/testing/src/schema_registry_mock.ts","../../../../../../packages/compiler/testing/src/directive_resolver_mock.ts","../../../../../../packages/compiler/testing/src/ng_module_resolver_mock.ts","../../../../../../packages/compiler/testing/src/pipe_resolver_mock.ts","../../../../../../packages/compiler/testing/src/testing.ts","../../../../../../packages/compiler/testing/public_api.ts","../../../../../../packages/compiler/testing/index.ts","../../../../../../packages/compiler/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 {ResourceLoader} from '@angular/compiler';\n\n/**\n * A mock implementation of {@link ResourceLoader} that allows outgoing requests to be mocked\n * and responded to within a single test, without going to the network.\n */\nexport class MockResourceLoader extends ResourceLoader {\n private _expectations: _Expectation[] = [];\n private _definitions = new Map<string, string>();\n private _requests: _PendingRequest[] = [];\n\n override get(url: string): Promise<string> {\n const request = new _PendingRequest(url);\n this._requests.push(request);\n return request.getPromise();\n }\n\n hasPendingRequests() {\n return !!this._requests.length;\n }\n\n /**\n * Add an expectation for the given URL. Incoming requests will be checked against\n * the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method\n * can be used to check if any expectations have not yet been met.\n *\n * The response given will be returned if the expectation matches.\n */\n expect(url: string, response: string) {\n const expectation = new _Expectation(url, response);\n this._expectations.push(expectation);\n }\n\n /**\n * Add a definition for the given URL to return the given response. Unlike expectations,\n * definitions have no order and will satisfy any matching request at any time. Also\n * unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`\n * to return an error.\n */\n when(url: string, response: string) {\n this._definitions.set(url, response);\n }\n\n /**\n * Process pending requests and verify there are no outstanding expectations. Also fails\n * if no requests are pending.\n */\n flush() {\n if (this._requests.length === 0) {\n throw new Error('No pending requests to flush');\n }\n\n do {\n this._processRequest(this._requests.shift()!);\n } while (this._requests.length > 0);\n\n this.verifyNoOutstandingExpectations();\n }\n\n /**\n * Throw an exception if any expectations have not been satisfied.\n */\n verifyNoOutstandingExpectations() {\n if (this._expectations.length === 0) return;\n\n const urls: string[] = [];\n for (let i = 0; i < this._expectations.length; i++) {\n const expectation = this._expectations[i];\n urls.push(expectation.url);\n }\n\n throw new Error(`Unsatisfied requests: ${urls.join(', ')}`);\n }\n\n private _processRequest(request: _PendingRequest) {\n const url = request.url;\n\n if (this._expectations.length > 0) {\n const expectation = this._expectations[0];\n if (expectation.url == url) {\n remove(this._expectations, expectation);\n request.complete(expectation.response);\n return;\n }\n }\n\n if (this._definitions.has(url)) {\n const response = this._definitions.get(url);\n request.complete(response == null ? null : response);\n return;\n }\n\n throw new Error(`Unexpected request ${url}`);\n }\n}\n\nclass _PendingRequest {\n // TODO(issue/24571): remove '!'.\n resolve!: (result: string) => void;\n // TODO(issue/24571): remove '!'.\n reject!: (error: any) => void;\n promise: Promise<string>;\n\n constructor(public url: string) {\n this.promise = new Promise((res, rej) => {\n this.resolve = res;\n this.reject = rej;\n });\n }\n\n complete(response: string|null) {\n if (response == null) {\n this.reject(`Failed to load ${this.url}`);\n } else {\n this.resolve(response);\n }\n }\n\n getPromise(): Promise<string> {\n return this.promise;\n }\n}\n\nclass _Expectation {\n url: string;\n response: string;\n constructor(url: string, response: string) {\n this.url = url;\n this.response = response;\n }\n}\n\nfunction remove<T>(list: T[], el: T): void {\n const index = list.indexOf(el);\n if (index > -1) {\n list.splice(index, 1);\n }\n}\n","/**\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 {core, ElementSchemaRegistry} from '@angular/compiler';\n\nexport class MockSchemaRegistry implements ElementSchemaRegistry {\n constructor(\n public existingProperties: {[key: string]: boolean},\n public attrPropMapping: {[key: string]: string},\n public existingElements: {[key: string]: boolean}, public invalidProperties: Array<string>,\n public invalidAttributes: Array<string>) {}\n\n hasProperty(tagName: string, property: string, schemas: core.SchemaMetadata[]): boolean {\n const value = this.existingProperties[property];\n return value === void 0 ? true : value;\n }\n\n hasElement(tagName: string, schemaMetas: core.SchemaMetadata[]): boolean {\n const value = this.existingElements[tagName.toLowerCase()];\n return value === void 0 ? true : value;\n }\n\n allKnownElementNames(): string[] {\n return Object.keys(this.existingElements);\n }\n\n securityContext(selector: string, property: string, isAttribute: boolean): core.SecurityContext {\n return core.SecurityContext.NONE;\n }\n\n getMappedPropName(attrName: string): string {\n return this.attrPropMapping[attrName] || attrName;\n }\n\n getDefaultComponentElementName(): string {\n return 'ng-component';\n }\n\n validateProperty(name: string): {error: boolean, msg?: string} {\n if (this.invalidProperties.indexOf(name) > -1) {\n return {error: true, msg: `Binding to property '${name}' is disallowed for security reasons`};\n } else {\n return {error: false};\n }\n }\n\n validateAttribute(name: string): {error: boolean, msg?: string} {\n if (this.invalidAttributes.indexOf(name) > -1) {\n return {\n error: true,\n msg: `Binding to attribute '${name}' is disallowed for security reasons`\n };\n } else {\n return {error: false};\n }\n }\n\n normalizeAnimationStyleProperty(propName: string): string {\n return propName;\n }\n normalizeAnimationStyleValue(camelCaseProp: string, userProvidedProp: string, val: string|number):\n {error: string, value: string} {\n return {error: null!, value: val.toString()};\n }\n}\n","/**\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 */\nimport {CompileReflector, core, DirectiveResolver} from '@angular/compiler';\n\n/**\n * An implementation of {@link DirectiveResolver} that allows overriding\n * various properties of directives.\n */\nexport class MockDirectiveResolver extends DirectiveResolver {\n private _directives = new Map<core.Type, core.Directive>();\n\n constructor(reflector: CompileReflector) {\n super(reflector);\n }\n\n override resolve(type: core.Type): core.Directive;\n override resolve(type: core.Type, throwIfNotFound: true): core.Directive;\n override resolve(type: core.Type, throwIfNotFound: boolean): core.Directive|null;\n override resolve(type: core.Type, throwIfNotFound = true): core.Directive|null {\n return this._directives.get(type) || super.resolve(type, throwIfNotFound);\n }\n\n /**\n * Overrides the {@link core.Directive} for a directive.\n */\n setDirective(type: core.Type, metadata: core.Directive): void {\n this._directives.set(type, metadata);\n }\n}\n","/**\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 {CompileReflector, core, NgModuleResolver} from '@angular/compiler';\n\nexport class MockNgModuleResolver extends NgModuleResolver {\n private _ngModules = new Map<core.Type, core.NgModule>();\n\n constructor(reflector: CompileReflector) {\n super(reflector);\n }\n\n /**\n * Overrides the {@link NgModule} for a module.\n */\n setNgModule(type: core.Type, metadata: core.NgModule): void {\n this._ngModules.set(type, metadata);\n }\n\n /**\n * Returns the {@link NgModule} for a module:\n * - Set the {@link NgModule} to the overridden view when it exists or fallback to the\n * default\n * `NgModuleResolver`, see `setNgModule`.\n */\n override resolve(type: core.Type, throwIfNotFound = true): core.NgModule {\n return this._ngModules.get(type) || super.resolve(type, throwIfNotFound)!;\n }\n}\n","/**\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 {CompileReflector, core, PipeResolver} from '@angular/compiler';\n\nexport class MockPipeResolver extends PipeResolver {\n private _pipes = new Map<core.Type, core.Pipe>();\n\n constructor(refector: CompileReflector) {\n super(refector);\n }\n\n /**\n * Overrides the {@link Pipe} for a pipe.\n */\n setPipe(type: core.Type, metadata: core.Pipe): void {\n this._pipes.set(type, metadata);\n }\n\n /**\n * Returns the {@link Pipe} for a pipe:\n * - Set the {@link Pipe} to the overridden view when it exists or fallback to the\n * default\n * `PipeResolver`, see `setPipe`.\n */\n override resolve(type: core.Type, throwIfNotFound = true): core.Pipe {\n let metadata = this._pipes.get(type);\n if (!metadata) {\n metadata = super.resolve(type, throwIfNotFound)!;\n }\n return metadata;\n }\n}\n","/**\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\n/**\n * @module\n * @description\n * Entry point for all APIs of the compiler package.\n *\n * <div class=\"callout is-critical\">\n * <header>Unstable APIs</header>\n * <p>\n * All compiler apis are currently considered experimental and private!\n * </p>\n * <p>\n * We expect the APIs in this package to keep on changing. Do not rely on them.\n * </p>\n * </div>\n */\nexport * from './resource_loader_mock';\nexport * from './schema_registry_mock';\nexport * from './directive_resolver_mock';\nexport * from './ng_module_resolver_mock';\nexport * from './pipe_resolver_mock';\n","/**\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\n/// <reference types=\"node\" />\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/testing';\n\n// This file only reexports content of the `src` folder. Keep it that way.\n","/**\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\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;AAUA;;;;MAIa,kBAAmB,SAAQ,cAAc;IAAtD;;QACU,kBAAa,GAAmB,EAAE,CAAC;QACnC,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,cAAS,GAAsB,EAAE,CAAC;KAqF3C;IAnFU,GAAG,CAAC,GAAW;QACtB,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7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