UNPKG

5.02 kBJavaScriptView Raw
1/**
2 * @license Angular v13.2.0
3 * (c) 2010-2022 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import * as i0 from '@angular/core';
8import { Injectable, Inject, createPlatformFactory, NgModule } from '@angular/core';
9import { TestComponentRenderer } from '@angular/core/testing';
10import { ɵplatformCoreDynamic, ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS } from '@angular/platform-browser-dynamic';
11import { BrowserTestingModule } from '@angular/platform-browser/testing';
12import { ɵgetDOM, DOCUMENT } from '@angular/common';
13
14/**
15 * @license
16 * Copyright Google LLC All Rights Reserved.
17 *
18 * Use of this source code is governed by an MIT-style license that can be
19 * found in the LICENSE file at https://angular.io/license
20 */
21/**
22 * A DOM based implementation of the TestComponentRenderer.
23 */
24class DOMTestComponentRenderer extends TestComponentRenderer {
25 constructor(_doc) {
26 super();
27 this._doc = _doc;
28 }
29 insertRootElement(rootElId) {
30 this.removeAllRootElements();
31 const rootElement = ɵgetDOM().getDefaultDocument().createElement('div');
32 rootElement.setAttribute('id', rootElId);
33 this._doc.body.appendChild(rootElement);
34 }
35 removeAllRootElements() {
36 // TODO(juliemr): can/should this be optional?
37 const oldRoots = this._doc.querySelectorAll('[id^=root]');
38 for (let i = 0; i < oldRoots.length; i++) {
39 ɵgetDOM().remove(oldRoots[i]);
40 }
41 }
42}
43DOMTestComponentRenderer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DOMTestComponentRenderer, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
44DOMTestComponentRenderer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DOMTestComponentRenderer });
45i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: DOMTestComponentRenderer, decorators: [{
46 type: Injectable
47 }], ctorParameters: function () { return [{ type: undefined, decorators: [{
48 type: Inject,
49 args: [DOCUMENT]
50 }] }]; } });
51
52/**
53 * @license
54 * Copyright Google LLC All Rights Reserved.
55 *
56 * Use of this source code is governed by an MIT-style license that can be
57 * found in the LICENSE file at https://angular.io/license
58 */
59/**
60 * Platform for dynamic tests
61 *
62 * @publicApi
63 */
64const platformCoreDynamicTesting = createPlatformFactory(ɵplatformCoreDynamic, 'coreDynamicTesting', []);
65
66/**
67 * @license
68 * Copyright Google LLC All Rights Reserved.
69 *
70 * Use of this source code is governed by an MIT-style license that can be
71 * found in the LICENSE file at https://angular.io/license
72 */
73
74/**
75 * @license
76 * Copyright Google LLC All Rights Reserved.
77 *
78 * Use of this source code is governed by an MIT-style license that can be
79 * found in the LICENSE file at https://angular.io/license
80 */
81/**
82 * @publicApi
83 */
84const platformBrowserDynamicTesting = createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
85/**
86 * NgModule for testing.
87 *
88 * @publicApi
89 */
90class BrowserDynamicTestingModule {
91}
92BrowserDynamicTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: BrowserDynamicTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
93BrowserDynamicTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: BrowserDynamicTestingModule, exports: [BrowserTestingModule] });
94BrowserDynamicTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: BrowserDynamicTestingModule, providers: [
95 { provide: TestComponentRenderer, useClass: DOMTestComponentRenderer },
96 ], imports: [BrowserTestingModule] });
97i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: BrowserDynamicTestingModule, decorators: [{
98 type: NgModule,
99 args: [{
100 exports: [BrowserTestingModule],
101 providers: [
102 { provide: TestComponentRenderer, useClass: DOMTestComponentRenderer },
103 ]
104 }]
105 }] });
106
107/**
108 * @license
109 * Copyright Google LLC All Rights Reserved.
110 *
111 * Use of this source code is governed by an MIT-style license that can be
112 * found in the LICENSE file at https://angular.io/license
113 */
114
115/**
116 * @license
117 * Copyright Google LLC All Rights Reserved.
118 *
119 * Use of this source code is governed by an MIT-style license that can be
120 * found in the LICENSE file at https://angular.io/license
121 */
122
123/**
124 * Generated bundle index. Do not edit.
125 */
126
127export { BrowserDynamicTestingModule, platformBrowserDynamicTesting, DOMTestComponentRenderer as ɵDOMTestComponentRenderer, platformCoreDynamicTesting as ɵplatformCoreDynamicTesting };
128//# sourceMappingURL=testing.mjs.map