source: trip-planner-front/node_modules/@angular/platform-browser-dynamic/fesm2015/testing.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 8.5 KB
Line 
1/**
2 * @license Angular v12.2.9
3 * (c) 2010-2021 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { Injectable, Inject, ɵstringify, NgModule, Directive, Component, Pipe, createPlatformFactory, COMPILER_OPTIONS, Injector, CompilerFactory } from '@angular/core';
8import { TestComponentRenderer, ɵMetadataOverrider, ɵTestingCompilerFactory } from '@angular/core/testing';
9import { ɵplatformCoreDynamic, ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS } from '@angular/platform-browser-dynamic';
10import { BrowserTestingModule } from '@angular/platform-browser/testing';
11import { ɵgetDOM, DOCUMENT } from '@angular/common';
12import { CompileReflector, PipeResolver, DirectiveResolver, NgModuleResolver, ERROR_COMPONENT_TYPE } from '@angular/compiler';
13import { MockPipeResolver, MockDirectiveResolver, MockNgModuleResolver } from '@angular/compiler/testing';
14
15/**
16 * @license
17 * Copyright Google LLC All Rights Reserved.
18 *
19 * Use of this source code is governed by an MIT-style license that can be
20 * found in the LICENSE file at https://angular.io/license
21 */
22/**
23 * A DOM based implementation of the TestComponentRenderer.
24 */
25class DOMTestComponentRenderer extends TestComponentRenderer {
26 constructor(_doc) {
27 super();
28 this._doc = _doc;
29 }
30 insertRootElement(rootElId) {
31 this.removeAllRootElements();
32 const rootElement = ɵgetDOM().getDefaultDocument().createElement('div');
33 rootElement.setAttribute('id', rootElId);
34 this._doc.body.appendChild(rootElement);
35 }
36 removeAllRootElements() {
37 // TODO(juliemr): can/should this be optional?
38 const oldRoots = this._doc.querySelectorAll('[id^=root]');
39 for (let i = 0; i < oldRoots.length; i++) {
40 ɵgetDOM().remove(oldRoots[i]);
41 }
42 }
43}
44DOMTestComponentRenderer.decorators = [
45 { type: Injectable }
46];
47DOMTestComponentRenderer.ctorParameters = () => [
48 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
49];
50
51/**
52 * @license
53 * Copyright Google LLC All Rights Reserved.
54 *
55 * Use of this source code is governed by an MIT-style license that can be
56 * found in the LICENSE file at https://angular.io/license
57 */
58
59/**
60 * @license
61 * Copyright Google LLC All Rights Reserved.
62 *
63 * Use of this source code is governed by an MIT-style license that can be
64 * found in the LICENSE file at https://angular.io/license
65 */
66const COMPILER_PROVIDERS = [
67 { provide: MockPipeResolver, deps: [CompileReflector] },
68 { provide: PipeResolver, useExisting: MockPipeResolver },
69 { provide: MockDirectiveResolver, deps: [CompileReflector] },
70 { provide: DirectiveResolver, useExisting: MockDirectiveResolver },
71 { provide: MockNgModuleResolver, deps: [CompileReflector] },
72 { provide: NgModuleResolver, useExisting: MockNgModuleResolver },
73];
74class TestingCompilerFactoryImpl {
75 constructor(_injector, _compilerFactory) {
76 this._injector = _injector;
77 this._compilerFactory = _compilerFactory;
78 }
79 createTestingCompiler(options) {
80 const compiler = this._compilerFactory.createCompiler(options);
81 return new TestingCompilerImpl(compiler, compiler.injector.get(MockDirectiveResolver), compiler.injector.get(MockPipeResolver), compiler.injector.get(MockNgModuleResolver));
82 }
83}
84class TestingCompilerImpl {
85 constructor(_compiler, _directiveResolver, _pipeResolver, _moduleResolver) {
86 this._compiler = _compiler;
87 this._directiveResolver = _directiveResolver;
88 this._pipeResolver = _pipeResolver;
89 this._moduleResolver = _moduleResolver;
90 this._overrider = new ɵMetadataOverrider();
91 }
92 get injector() {
93 return this._compiler.injector;
94 }
95 compileModuleSync(moduleType) {
96 return this._compiler.compileModuleSync(moduleType);
97 }
98 compileModuleAsync(moduleType) {
99 return this._compiler.compileModuleAsync(moduleType);
100 }
101 compileModuleAndAllComponentsSync(moduleType) {
102 return this._compiler.compileModuleAndAllComponentsSync(moduleType);
103 }
104 compileModuleAndAllComponentsAsync(moduleType) {
105 return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
106 }
107 getComponentFactory(component) {
108 return this._compiler.getComponentFactory(component);
109 }
110 checkOverrideAllowed(type) {
111 if (this._compiler.hasAotSummary(type)) {
112 throw new Error(`${ɵstringify(type)} was AOT compiled, so its metadata cannot be changed.`);
113 }
114 }
115 overrideModule(ngModule, override) {
116 this.checkOverrideAllowed(ngModule);
117 const oldMetadata = this._moduleResolver.resolve(ngModule, false);
118 this._moduleResolver.setNgModule(ngModule, this._overrider.overrideMetadata(NgModule, oldMetadata, override));
119 this.clearCacheFor(ngModule);
120 }
121 overrideDirective(directive, override) {
122 this.checkOverrideAllowed(directive);
123 const oldMetadata = this._directiveResolver.resolve(directive, false);
124 this._directiveResolver.setDirective(directive, this._overrider.overrideMetadata(Directive, oldMetadata, override));
125 this.clearCacheFor(directive);
126 }
127 overrideComponent(component, override) {
128 this.checkOverrideAllowed(component);
129 const oldMetadata = this._directiveResolver.resolve(component, false);
130 this._directiveResolver.setDirective(component, this._overrider.overrideMetadata(Component, oldMetadata, override));
131 this.clearCacheFor(component);
132 }
133 overridePipe(pipe, override) {
134 this.checkOverrideAllowed(pipe);
135 const oldMetadata = this._pipeResolver.resolve(pipe, false);
136 this._pipeResolver.setPipe(pipe, this._overrider.overrideMetadata(Pipe, oldMetadata, override));
137 this.clearCacheFor(pipe);
138 }
139 loadAotSummaries(summaries) {
140 this._compiler.loadAotSummaries(summaries);
141 }
142 clearCache() {
143 this._compiler.clearCache();
144 }
145 clearCacheFor(type) {
146 this._compiler.clearCacheFor(type);
147 }
148 getComponentFromError(error) {
149 return error[ERROR_COMPONENT_TYPE] || null;
150 }
151 getModuleId(moduleType) {
152 return this._moduleResolver.resolve(moduleType, true).id;
153 }
154}
155
156/**
157 * @license
158 * Copyright Google LLC All Rights Reserved.
159 *
160 * Use of this source code is governed by an MIT-style license that can be
161 * found in the LICENSE file at https://angular.io/license
162 */
163const ɵ0 = { providers: COMPILER_PROVIDERS };
164/**
165 * Platform for dynamic tests
166 *
167 * @publicApi
168 */
169const platformCoreDynamicTesting = createPlatformFactory(ɵplatformCoreDynamic, 'coreDynamicTesting', [
170 { provide: COMPILER_OPTIONS, useValue: ɵ0, multi: true }, {
171 provide: ɵTestingCompilerFactory,
172 useClass: TestingCompilerFactoryImpl,
173 deps: [Injector, CompilerFactory]
174 }
175]);
176
177/**
178 * @license
179 * Copyright Google LLC All Rights Reserved.
180 *
181 * Use of this source code is governed by an MIT-style license that can be
182 * found in the LICENSE file at https://angular.io/license
183 */
184
185/**
186 * @license
187 * Copyright Google LLC All Rights Reserved.
188 *
189 * Use of this source code is governed by an MIT-style license that can be
190 * found in the LICENSE file at https://angular.io/license
191 */
192/**
193 * @publicApi
194 */
195const platformBrowserDynamicTesting = createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
196/**
197 * NgModule for testing.
198 *
199 * @publicApi
200 */
201class BrowserDynamicTestingModule {
202}
203BrowserDynamicTestingModule.decorators = [
204 { type: NgModule, args: [{
205 exports: [BrowserTestingModule],
206 providers: [
207 { provide: TestComponentRenderer, useClass: DOMTestComponentRenderer },
208 ]
209 },] }
210];
211
212/**
213 * @license
214 * Copyright Google LLC All Rights Reserved.
215 *
216 * Use of this source code is governed by an MIT-style license that can be
217 * found in the LICENSE file at https://angular.io/license
218 */
219
220/**
221 * @license
222 * Copyright Google LLC All Rights Reserved.
223 *
224 * Use of this source code is governed by an MIT-style license that can be
225 * found in the LICENSE file at https://angular.io/license
226 */
227
228/**
229 * Generated bundle index. Do not edit.
230 */
231
232export { BrowserDynamicTestingModule, platformBrowserDynamicTesting, DOMTestComponentRenderer as ɵDOMTestComponentRenderer, COMPILER_PROVIDERS as ɵangular_packages_platform_browser_dynamic_testing_testing_a, TestingCompilerFactoryImpl as ɵangular_packages_platform_browser_dynamic_testing_testing_b, platformCoreDynamicTesting as ɵplatformCoreDynamicTesting };
233//# sourceMappingURL=testing.js.map
Note: See TracBrowser for help on using the repository browser.