source: trip-planner-front/node_modules/@angular/cdk/esm2015/testing/testbed/testbed-harness-environment.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 23.1 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { handleAutoChangeDetectionStatus, HarnessEnvironment, stopHandlingAutoChangeDetectionStatus } from '@angular/cdk/testing';
10import { flush } from '@angular/core/testing';
11import { takeWhile } from 'rxjs/operators';
12import { TaskStateZoneInterceptor } from './task-state-zone-interceptor';
13import { UnitTestElement } from './unit-test-element';
14/** The default environment options. */
15const defaultEnvironmentOptions = {
16 queryFn: (selector, root) => root.querySelectorAll(selector)
17};
18/** Whether auto change detection is currently disabled. */
19let disableAutoChangeDetection = false;
20/**
21 * The set of non-destroyed fixtures currently being used by `TestbedHarnessEnvironment` instances.
22 */
23const activeFixtures = new Set();
24/**
25 * Installs a handler for change detection batching status changes for a specific fixture.
26 * @param fixture The fixture to handle change detection batching for.
27 */
28function installAutoChangeDetectionStatusHandler(fixture) {
29 if (!activeFixtures.size) {
30 handleAutoChangeDetectionStatus(({ isDisabled, onDetectChangesNow }) => {
31 disableAutoChangeDetection = isDisabled;
32 if (onDetectChangesNow) {
33 Promise.all(Array.from(activeFixtures).map(detectChanges)).then(onDetectChangesNow);
34 }
35 });
36 }
37 activeFixtures.add(fixture);
38}
39/**
40 * Uninstalls a handler for change detection batching status changes for a specific fixture.
41 * @param fixture The fixture to stop handling change detection batching for.
42 */
43function uninstallAutoChangeDetectionStatusHandler(fixture) {
44 activeFixtures.delete(fixture);
45 if (!activeFixtures.size) {
46 stopHandlingAutoChangeDetectionStatus();
47 }
48}
49/** Whether we are currently in the fake async zone. */
50function isInFakeAsyncZone() {
51 return Zone.current.get('FakeAsyncTestZoneSpec') != null;
52}
53/**
54 * Triggers change detection for a specific fixture.
55 * @param fixture The fixture to trigger change detection for.
56 */
57function detectChanges(fixture) {
58 return __awaiter(this, void 0, void 0, function* () {
59 fixture.detectChanges();
60 if (isInFakeAsyncZone()) {
61 flush();
62 }
63 else {
64 yield fixture.whenStable();
65 }
66 });
67}
68/** A `HarnessEnvironment` implementation for Angular's Testbed. */
69export class TestbedHarnessEnvironment extends HarnessEnvironment {
70 constructor(rawRootElement, _fixture, options) {
71 super(rawRootElement);
72 this._fixture = _fixture;
73 /** Whether the environment has been destroyed. */
74 this._destroyed = false;
75 this._options = Object.assign(Object.assign({}, defaultEnvironmentOptions), options);
76 this._taskState = TaskStateZoneInterceptor.setup();
77 installAutoChangeDetectionStatusHandler(_fixture);
78 _fixture.componentRef.onDestroy(() => {
79 uninstallAutoChangeDetectionStatusHandler(_fixture);
80 this._destroyed = true;
81 });
82 }
83 /** Creates a `HarnessLoader` rooted at the given fixture's root element. */
84 static loader(fixture, options) {
85 return new TestbedHarnessEnvironment(fixture.nativeElement, fixture, options);
86 }
87 /**
88 * Creates a `HarnessLoader` at the document root. This can be used if harnesses are
89 * located outside of a fixture (e.g. overlays appended to the document body).
90 */
91 static documentRootLoader(fixture, options) {
92 return new TestbedHarnessEnvironment(document.body, fixture, options);
93 }
94 /** Gets the native DOM element corresponding to the given TestElement. */
95 static getNativeElement(el) {
96 if (el instanceof UnitTestElement) {
97 return el.element;
98 }
99 throw Error('This TestElement was not created by the TestbedHarnessEnvironment');
100 }
101 /**
102 * Creates an instance of the given harness type, using the fixture's root element as the
103 * harness's host element. This method should be used when creating a harness for the root element
104 * of a fixture, as components do not have the correct selector when they are created as the root
105 * of the fixture.
106 */
107 static harnessForFixture(fixture, harnessType, options) {
108 return __awaiter(this, void 0, void 0, function* () {
109 const environment = new TestbedHarnessEnvironment(fixture.nativeElement, fixture, options);
110 yield environment.forceStabilize();
111 return environment.createComponentHarness(harnessType, fixture.nativeElement);
112 });
113 }
114 /**
115 * Flushes change detection and async tasks captured in the Angular zone.
116 * In most cases it should not be necessary to call this manually. However, there may be some edge
117 * cases where it is needed to fully flush animation events.
118 */
119 forceStabilize() {
120 return __awaiter(this, void 0, void 0, function* () {
121 if (!disableAutoChangeDetection) {
122 if (this._destroyed) {
123 throw Error('Harness is attempting to use a fixture that has already been destroyed.');
124 }
125 yield detectChanges(this._fixture);
126 }
127 });
128 }
129 /**
130 * Waits for all scheduled or running async tasks to complete. This allows harness
131 * authors to wait for async tasks outside of the Angular zone.
132 */
133 waitForTasksOutsideAngular() {
134 return __awaiter(this, void 0, void 0, function* () {
135 // If we run in the fake async zone, we run "flush" to run any scheduled tasks. This
136 // ensures that the harnesses behave inside of the FakeAsyncTestZone similar to the
137 // "AsyncTestZone" and the root zone (i.e. neither fakeAsync or async). Note that we
138 // cannot just rely on the task state observable to become stable because the state will
139 // never change. This is because the task queue will be only drained if the fake async
140 // zone is being flushed.
141 if (isInFakeAsyncZone()) {
142 flush();
143 }
144 // Wait until the task queue has been drained and the zone is stable. Note that
145 // we cannot rely on "fixture.whenStable" since it does not catch tasks scheduled
146 // outside of the Angular zone. For test harnesses, we want to ensure that the
147 // app is fully stabilized and therefore need to use our own zone interceptor.
148 yield this._taskState.pipe(takeWhile(state => !state.stable)).toPromise();
149 });
150 }
151 /** Gets the root element for the document. */
152 getDocumentRoot() {
153 return document.body;
154 }
155 /** Creates a `TestElement` from a raw element. */
156 createTestElement(element) {
157 return new UnitTestElement(element, () => this.forceStabilize());
158 }
159 /** Creates a `HarnessLoader` rooted at the given raw element. */
160 createEnvironment(element) {
161 return new TestbedHarnessEnvironment(element, this._fixture, this._options);
162 }
163 /**
164 * Gets a list of all elements matching the given selector under this environment's root element.
165 */
166 getAllRawElements(selector) {
167 return __awaiter(this, void 0, void 0, function* () {
168 yield this.forceStabilize();
169 return Array.from(this._options.queryFn(selector, this.rawRootElement));
170 });
171 }
172}
173//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGJlZ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