1
|
/**
|
2
|
* @license Angular v4.4.6
|
3
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
4
|
* License: MIT
|
5
|
*/
|
6
|
import { platformCoreDynamicTesting } from '@angular/compiler/testing';
|
7
|
import { Inject, Injectable, NgModule, createPlatformFactory } from '@angular/core';
|
8
|
import { TestComponentRenderer } from '@angular/core/testing';
|
9
|
import { ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS } from '@angular/platform-browser-dynamic';
|
10
|
import { BrowserTestingModule } from '@angular/platform-browser/testing';
|
11
|
import { DOCUMENT, ɵgetDOM } from '@angular/platform-browser';
|
12
|
|
13
|
/**
|
14
|
* @license
|
15
|
* Copyright Google Inc. All Rights Reserved.
|
16
|
*
|
17
|
* Use of this source code is governed by an MIT-style license that can be
|
18
|
* found in the LICENSE file at https://angular.io/license
|
19
|
*/
|
20
|
/**
|
21
|
* A DOM based implementation of the TestComponentRenderer.
|
22
|
*/
|
23
|
class DOMTestComponentRenderer extends TestComponentRenderer {
|
24
|
constructor(_doc /** TODO #9100 */) {
|
25
|
super();
|
26
|
this._doc = _doc; /** TODO #9100 */
|
27
|
}
|
28
|
insertRootElement(rootElId) {
|
29
|
const rootEl = ɵgetDOM().firstChild(ɵgetDOM().content(ɵgetDOM().createTemplate(`<div id="${rootElId}"></div>`)));
|
30
|
// TODO(juliemr): can/should this be optional?
|
31
|
const oldRoots = ɵgetDOM().querySelectorAll(this._doc, '[id^=root]');
|
32
|
for (let i = 0; i < oldRoots.length; i++) {
|
33
|
ɵgetDOM().remove(oldRoots[i]);
|
34
|
}
|
35
|
ɵgetDOM().appendChild(this._doc.body, rootEl);
|
36
|
}
|
37
|
}
|
38
|
DOMTestComponentRenderer.decorators = [
|
39
|
{ type: Injectable },
|
40
|
];
|
41
|
/** @nocollapse */
|
42
|
DOMTestComponentRenderer.ctorParameters = () => [
|
43
|
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
|
44
|
];
|
45
|
|
46
|
/**
|
47
|
* @license
|
48
|
* Copyright Google Inc. All Rights Reserved.
|
49
|
*
|
50
|
* Use of this source code is governed by an MIT-style license that can be
|
51
|
* found in the LICENSE file at https://angular.io/license
|
52
|
*/
|
53
|
|
54
|
/**
|
55
|
* @license
|
56
|
* Copyright Google Inc. All Rights Reserved.
|
57
|
*
|
58
|
* Use of this source code is governed by an MIT-style license that can be
|
59
|
* found in the LICENSE file at https://angular.io/license
|
60
|
*/
|
61
|
/**
|
62
|
* @stable
|
63
|
*/
|
64
|
const platformBrowserDynamicTesting = createPlatformFactory(platformCoreDynamicTesting, 'browserDynamicTesting', ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
|
65
|
/**
|
66
|
* NgModule for testing.
|
67
|
*
|
68
|
* @stable
|
69
|
*/
|
70
|
class BrowserDynamicTestingModule {
|
71
|
}
|
72
|
BrowserDynamicTestingModule.decorators = [
|
73
|
{ type: NgModule, args: [{
|
74
|
exports: [BrowserTestingModule],
|
75
|
providers: [
|
76
|
{ provide: TestComponentRenderer, useClass: DOMTestComponentRenderer },
|
77
|
]
|
78
|
},] },
|
79
|
];
|
80
|
/** @nocollapse */
|
81
|
BrowserDynamicTestingModule.ctorParameters = () => [];
|
82
|
|
83
|
/**
|
84
|
* @license
|
85
|
* Copyright Google Inc. All Rights Reserved.
|
86
|
*
|
87
|
* Use of this source code is governed by an MIT-style license that can be
|
88
|
* found in the LICENSE file at https://angular.io/license
|
89
|
*/
|
90
|
/**
|
91
|
* @module
|
92
|
* @description
|
93
|
* Entry point for all public APIs of the platform-browser-dynamic/testing package.
|
94
|
*/
|
95
|
|
96
|
export { platformBrowserDynamicTesting, BrowserDynamicTestingModule, DOMTestComponentRenderer as ɵDOMTestComponentRenderer };
|
97
|
//# sourceMappingURL=testing.js.map
|