@angular/core 11.0.0-rc.3 → 11.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/core-testing.umd.js +16 -281
- package/bundles/core-testing.umd.js.map +1 -1
- package/bundles/core-testing.umd.min.js +11 -25
- package/bundles/core-testing.umd.min.js.map +1 -1
- package/bundles/core.umd.js +11847 -11799
- package/bundles/core.umd.js.map +1 -1
- package/bundles/core.umd.min.js +187 -173
- package/bundles/core.umd.min.js.map +1 -1
- package/core.d.ts +256 -192
- package/core.metadata.json +1 -1
- package/esm2015/core.js +31 -24
- package/esm2015/src/application_init.js +5 -2
- package/esm2015/src/change_detection/change_detector_ref.js +49 -9
- package/esm2015/src/compiler/compiler_facade_interface.js +1 -1
- package/esm2015/src/core_render3_private_export.js +2 -1
- package/esm2015/src/debug/debug_node.js +3 -2
- package/esm2015/src/di/index.js +3 -2
- package/esm2015/src/di/inject_switch.js +63 -0
- package/esm2015/src/di/injection_token.js +5 -3
- package/esm2015/src/di/injector.js +5 -3
- package/esm2015/src/di/injector_compatibility.js +3 -77
- package/esm2015/src/di/injector_marker.js +9 -0
- package/esm2015/src/di/injector_token.js +21 -0
- package/esm2015/src/di/interface/defs.js +2 -2
- package/esm2015/src/di/jit/util.js +4 -4
- package/esm2015/src/di/metadata.js +2 -10
- package/esm2015/src/di/metadata_attr.js +24 -0
- package/esm2015/src/di/null_injector.js +20 -0
- package/esm2015/src/di/r3_injector.js +6 -4
- package/esm2015/src/linker/compiler.js +1 -1
- package/esm2015/src/linker/element_ref.js +26 -7
- package/esm2015/src/linker/ng_module_factory_loader.js +1 -1
- package/esm2015/src/linker/ng_module_factory_registration.js +1 -1
- package/esm2015/src/linker/template_ref.js +56 -7
- package/esm2015/src/linker/view_container_ref.js +223 -7
- package/esm2015/src/linker/view_ref.js +1 -1
- package/esm2015/src/metadata/directives.js +1 -1
- package/esm2015/src/metadata/do_boostrap.js +9 -0
- package/esm2015/src/metadata/ng_module.js +1 -1
- package/esm2015/src/metadata/ng_module_def.js +9 -0
- package/esm2015/src/metadata.js +6 -2
- package/esm2015/src/r3_symbols.js +1 -1
- package/esm2015/src/render/api.js +24 -21
- package/esm2015/src/render/api_flags.js +26 -0
- package/esm2015/src/render.js +3 -2
- package/esm2015/src/render3/collect_native_nodes.js +68 -0
- package/esm2015/src/render3/component.js +2 -2
- package/esm2015/src/render3/component_ref.js +3 -4
- package/esm2015/src/render3/context_discovery.js +1 -1
- package/esm2015/src/render3/definition.js +9 -10
- package/esm2015/src/render3/definition_factory.js +17 -0
- package/esm2015/src/render3/di.js +26 -34
- package/esm2015/src/render3/errors.js +9 -25
- package/esm2015/src/render3/errors_di.js +26 -0
- package/esm2015/src/render3/i18n/i18n_apply.js +2 -2
- package/esm2015/src/render3/i18n/i18n_parse.js +3 -2
- package/esm2015/src/render3/i18n/i18n_tree_shaking.js +1 -1
- package/esm2015/src/render3/index.js +1 -1
- package/esm2015/src/render3/instructions/all.js +2 -1
- package/esm2015/src/render3/instructions/di.js +5 -12
- package/esm2015/src/render3/instructions/di_attr.js +18 -0
- package/esm2015/src/render3/instructions/element.js +1 -1
- package/esm2015/src/render3/instructions/i18n_icu_container_visitor.js +1 -1
- package/esm2015/src/render3/instructions/interpolation.js +2 -2
- package/esm2015/src/render3/instructions/listener.js +6 -1
- package/esm2015/src/render3/instructions/lview_debug.js +1 -1
- package/esm2015/src/render3/instructions/shared.js +4 -3
- package/esm2015/src/render3/instructions/styling.js +1 -1
- package/esm2015/src/render3/interfaces/container.js +1 -1
- package/esm2015/src/render3/interfaces/context.js +1 -1
- package/esm2015/src/render3/interfaces/definition.js +1 -1
- package/esm2015/src/render3/interfaces/node.js +1 -1
- package/esm2015/src/render3/interfaces/renderer.js +1 -1
- package/esm2015/src/render3/interfaces/renderer_dom.js +11 -0
- package/esm2015/src/render3/interfaces/type_checks.js +1 -1
- package/esm2015/src/render3/interfaces/view.js +1 -1
- package/esm2015/src/render3/jit/directive.js +2 -2
- package/esm2015/src/render3/jit/module.js +3 -2
- package/esm2015/src/render3/ng_module_ref.js +2 -2
- package/esm2015/src/render3/node_manipulation.js +13 -8
- package/esm2015/src/render3/node_manipulation_i18n.js +1 -1
- package/esm2015/src/render3/pipe.js +3 -3
- package/esm2015/src/render3/query.js +9 -10
- package/esm2015/src/render3/util/attrs_utils.js +1 -1
- package/esm2015/src/render3/util/discovery_utils.js +2 -2
- package/esm2015/src/render3/util/misc_utils.js +1 -26
- package/esm2015/src/render3/util/stringify_utils.js +36 -0
- package/esm2015/src/render3/util/view_utils.js +1 -1
- package/esm2015/src/render3/view_engine_compatibility_prebound.js +6 -7
- package/esm2015/src/render3/view_ref.js +3 -61
- package/esm2015/src/sanitization/bypass.js +3 -3
- package/esm2015/src/sanitization/html_sanitizer.js +6 -6
- package/esm2015/src/sanitization/sanitization.js +3 -3
- package/esm2015/src/sanitization/url_sanitizer.js +2 -2
- package/esm2015/src/util/lang.js +7 -3
- package/esm2015/src/version.js +1 -1
- package/esm2015/src/view/element.js +1 -1
- package/esm2015/src/view/ng_module.js +3 -2
- package/esm2015/src/view/refs.js +1 -1
- package/esm2015/src/view/services.js +1 -1
- package/esm2015/src/view/types.js +1 -1
- package/esm2015/src/view/util.js +1 -1
- package/esm2015/src/zone/ng_zone.js +2 -5
- package/esm2015/testing/src/async.js +5 -6
- package/esm2015/testing/src/fake_async.js +9 -20
- package/fesm2015/core.js +9405 -9333
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +17 -274
- package/fesm2015/testing.js.map +1 -1
- package/package.json +1 -1
- package/schematics/migrations/abstract-control-parent/index.js +2 -2
- package/schematics/migrations/dynamic-queries/index.js +2 -2
- package/schematics/migrations/initial-navigation/index.js +3 -3
- package/schematics/migrations/initial-navigation/transform.d.ts +1 -2
- package/schematics/migrations/initial-navigation/transform.js +2 -13
- package/schematics/migrations/missing-injectable/index.js +2 -2
- package/schematics/migrations/module-with-providers/index.js +2 -2
- package/schematics/migrations/move-document/index.js +2 -2
- package/schematics/migrations/native-view-encapsulation/index.js +2 -2
- package/schematics/migrations/navigation-extras-omissions/index.js +2 -2
- package/schematics/migrations/relative-link-resolution/index.js +2 -2
- package/schematics/migrations/renderer-to-renderer2/index.js +2 -2
- package/schematics/migrations/router-preserve-query-params/index.js +2 -2
- package/schematics/migrations/router-preserve-query-params/util.js +2 -2
- package/schematics/migrations/static-queries/index.js +2 -2
- package/schematics/migrations/template-var-assignment/index.js +2 -2
- package/schematics/migrations/undecorated-classes-with-decorated-fields/index.js +2 -2
- package/schematics/migrations/undecorated-classes-with-di/index.js +2 -2
- package/schematics/migrations/wait-for-async/index.js +2 -2
- package/schematics/migrations.json +1 -1
- package/schematics/utils/typescript/compiler_host.d.ts +7 -0
- package/schematics/utils/typescript/compiler_host.js +21 -2
- package/src/r3_symbols.d.ts +3 -3
- package/testing/testing.d.ts +1 -1
- package/testing.d.ts +1 -1
- package/esm2015/src/render3/view_engine_compatibility.js +0 -362
- package/esm2015/testing/src/async_fallback.js +0 -102
- package/esm2015/testing/src/fake_async_fallback.js +0 -145
package/fesm2015/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v11.0.
|
|
2
|
+
* @license Angular v11.0.3
|
|
3
3
|
* (c) 2010-2020 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -8,108 +8,6 @@ import { getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities,
|
|
|
8
8
|
import { __awaiter } from 'tslib';
|
|
9
9
|
import { ResourceLoader } from '@angular/compiler';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* @license
|
|
13
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14
|
-
*
|
|
15
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
16
|
-
* found in the LICENSE file at https://angular.io/license
|
|
17
|
-
*/
|
|
18
|
-
const _global = (typeof window === 'undefined' ? global : window);
|
|
19
|
-
/**
|
|
20
|
-
* Wraps a test function in an asynchronous test zone. The test will automatically
|
|
21
|
-
* complete when all asynchronous calls within this zone are done. Can be used
|
|
22
|
-
* to wrap an {@link inject} call.
|
|
23
|
-
*
|
|
24
|
-
* Example:
|
|
25
|
-
*
|
|
26
|
-
* ```
|
|
27
|
-
* it('...', async(inject([AClass], (object) => {
|
|
28
|
-
* object.doSomething.then(() => {
|
|
29
|
-
* expect(...);
|
|
30
|
-
* })
|
|
31
|
-
* });
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
function asyncFallback(fn) {
|
|
37
|
-
// If we're running using the Jasmine test framework, adapt to call the 'done'
|
|
38
|
-
// function when asynchronous activity is finished.
|
|
39
|
-
if (_global.jasmine) {
|
|
40
|
-
// Not using an arrow function to preserve context passed from call site
|
|
41
|
-
return function (done) {
|
|
42
|
-
if (!done) {
|
|
43
|
-
// if we run beforeEach in @angular/core/testing/testing_internal then we get no done
|
|
44
|
-
// fake it here and assume sync.
|
|
45
|
-
done = function () { };
|
|
46
|
-
done.fail = function (e) {
|
|
47
|
-
throw e;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
runInTestZone(fn, this, done, (err) => {
|
|
51
|
-
if (typeof err === 'string') {
|
|
52
|
-
return done.fail(new Error(err));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
done.fail(err);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Otherwise, return a promise which will resolve when asynchronous activity
|
|
61
|
-
// is finished. This will be correctly consumed by the Mocha framework with
|
|
62
|
-
// it('...', async(myFn)); or can be used in a custom framework.
|
|
63
|
-
// Not using an arrow function to preserve context passed from call site
|
|
64
|
-
return function () {
|
|
65
|
-
return new Promise((finishCallback, failCallback) => {
|
|
66
|
-
runInTestZone(fn, this, finishCallback, failCallback);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function runInTestZone(fn, context, finishCallback, failCallback) {
|
|
71
|
-
const currentZone = Zone.current;
|
|
72
|
-
const AsyncTestZoneSpec = Zone['AsyncTestZoneSpec'];
|
|
73
|
-
if (AsyncTestZoneSpec === undefined) {
|
|
74
|
-
throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' +
|
|
75
|
-
'Please make sure that your environment includes zone.js/dist/async-test.js');
|
|
76
|
-
}
|
|
77
|
-
const ProxyZoneSpec = Zone['ProxyZoneSpec'];
|
|
78
|
-
if (ProxyZoneSpec === undefined) {
|
|
79
|
-
throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' +
|
|
80
|
-
'Please make sure that your environment includes zone.js/dist/proxy.js');
|
|
81
|
-
}
|
|
82
|
-
const proxyZoneSpec = ProxyZoneSpec.get();
|
|
83
|
-
ProxyZoneSpec.assertPresent();
|
|
84
|
-
// We need to create the AsyncTestZoneSpec outside the ProxyZone.
|
|
85
|
-
// If we do it in ProxyZone then we will get to infinite recursion.
|
|
86
|
-
const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
|
|
87
|
-
const previousDelegate = proxyZoneSpec.getDelegate();
|
|
88
|
-
proxyZone.parent.run(() => {
|
|
89
|
-
const testZoneSpec = new AsyncTestZoneSpec(() => {
|
|
90
|
-
// Need to restore the original zone.
|
|
91
|
-
currentZone.run(() => {
|
|
92
|
-
if (proxyZoneSpec.getDelegate() == testZoneSpec) {
|
|
93
|
-
// Only reset the zone spec if it's sill this one. Otherwise, assume it's OK.
|
|
94
|
-
proxyZoneSpec.setDelegate(previousDelegate);
|
|
95
|
-
}
|
|
96
|
-
finishCallback();
|
|
97
|
-
});
|
|
98
|
-
}, (error) => {
|
|
99
|
-
// Need to restore the original zone.
|
|
100
|
-
currentZone.run(() => {
|
|
101
|
-
if (proxyZoneSpec.getDelegate() == testZoneSpec) {
|
|
102
|
-
// Only reset the zone spec if it's sill this one. Otherwise, assume it's OK.
|
|
103
|
-
proxyZoneSpec.setDelegate(previousDelegate);
|
|
104
|
-
}
|
|
105
|
-
failCallback(error);
|
|
106
|
-
});
|
|
107
|
-
}, 'test');
|
|
108
|
-
proxyZoneSpec.setDelegate(testZoneSpec);
|
|
109
|
-
});
|
|
110
|
-
return Zone.current.runGuarded(fn, context);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
11
|
/**
|
|
114
12
|
* @license
|
|
115
13
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -146,10 +44,10 @@ function waitForAsync(fn) {
|
|
|
146
44
|
if (typeof asyncTest === 'function') {
|
|
147
45
|
return asyncTest(fn);
|
|
148
46
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
47
|
+
return function () {
|
|
48
|
+
return Promise.reject('zone-testing.js is needed for the async() test helper but could not be found. ' +
|
|
49
|
+
'Please make sure that your environment includes zone.js/dist/zone-testing.js');
|
|
50
|
+
};
|
|
153
51
|
}
|
|
154
52
|
/**
|
|
155
53
|
* @deprecated use `waitForAsync()`, (expected removal in v12)
|
|
@@ -358,153 +256,10 @@ function scheduleMicroTask(fn) {
|
|
|
358
256
|
* Use of this source code is governed by an MIT-style license that can be
|
|
359
257
|
* found in the LICENSE file at https://angular.io/license
|
|
360
258
|
*/
|
|
361
|
-
/**
|
|
362
|
-
* fakeAsync has been moved to zone.js
|
|
363
|
-
* this file is for fallback in case old version of zone.js is used
|
|
364
|
-
*/
|
|
365
259
|
const _Zone = typeof Zone !== 'undefined' ? Zone : null;
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Clears out the shared fake async zone for a test.
|
|
371
|
-
* To be called in a global `beforeEach`.
|
|
372
|
-
*
|
|
373
|
-
* @publicApi
|
|
374
|
-
*/
|
|
375
|
-
function resetFakeAsyncZoneFallback() {
|
|
376
|
-
if (_fakeAsyncTestZoneSpec) {
|
|
377
|
-
_fakeAsyncTestZoneSpec.unlockDatePatch();
|
|
378
|
-
}
|
|
379
|
-
_fakeAsyncTestZoneSpec = null;
|
|
380
|
-
// in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset.
|
|
381
|
-
ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate();
|
|
382
|
-
}
|
|
383
|
-
let _inFakeAsyncCall = false;
|
|
384
|
-
/**
|
|
385
|
-
* Wraps a function to be executed in the fakeAsync zone:
|
|
386
|
-
* - microtasks are manually executed by calling `flushMicrotasks()`,
|
|
387
|
-
* - timers are synchronous, `tick()` simulates the asynchronous passage of time.
|
|
388
|
-
*
|
|
389
|
-
* If there are any pending timers at the end of the function, an exception will be thrown.
|
|
390
|
-
*
|
|
391
|
-
* Can be used to wrap inject() calls.
|
|
392
|
-
*
|
|
393
|
-
* @usageNotes
|
|
394
|
-
* ### Example
|
|
395
|
-
*
|
|
396
|
-
* {@example core/testing/ts/fake_async.ts region='basic'}
|
|
397
|
-
*
|
|
398
|
-
* @param fn
|
|
399
|
-
* @returns The function wrapped to be executed in the fakeAsync zone
|
|
400
|
-
*
|
|
401
|
-
* @publicApi
|
|
402
|
-
*/
|
|
403
|
-
function fakeAsyncFallback(fn) {
|
|
404
|
-
// Not using an arrow function to preserve context passed from call site
|
|
405
|
-
return function (...args) {
|
|
406
|
-
const proxyZoneSpec = ProxyZoneSpec.assertPresent();
|
|
407
|
-
if (_inFakeAsyncCall) {
|
|
408
|
-
throw new Error('fakeAsync() calls can not be nested');
|
|
409
|
-
}
|
|
410
|
-
_inFakeAsyncCall = true;
|
|
411
|
-
try {
|
|
412
|
-
if (!_fakeAsyncTestZoneSpec) {
|
|
413
|
-
if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) {
|
|
414
|
-
throw new Error('fakeAsync() calls can not be nested');
|
|
415
|
-
}
|
|
416
|
-
_fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec();
|
|
417
|
-
}
|
|
418
|
-
let res;
|
|
419
|
-
const lastProxyZoneSpec = proxyZoneSpec.getDelegate();
|
|
420
|
-
proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec);
|
|
421
|
-
_fakeAsyncTestZoneSpec.lockDatePatch();
|
|
422
|
-
try {
|
|
423
|
-
res = fn.apply(this, args);
|
|
424
|
-
flushMicrotasksFallback();
|
|
425
|
-
}
|
|
426
|
-
finally {
|
|
427
|
-
proxyZoneSpec.setDelegate(lastProxyZoneSpec);
|
|
428
|
-
}
|
|
429
|
-
if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) {
|
|
430
|
-
throw new Error(`${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` +
|
|
431
|
-
`periodic timer(s) still in the queue.`);
|
|
432
|
-
}
|
|
433
|
-
if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) {
|
|
434
|
-
throw new Error(`${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`);
|
|
435
|
-
}
|
|
436
|
-
return res;
|
|
437
|
-
}
|
|
438
|
-
finally {
|
|
439
|
-
_inFakeAsyncCall = false;
|
|
440
|
-
resetFakeAsyncZoneFallback();
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
function _getFakeAsyncZoneSpec() {
|
|
445
|
-
if (_fakeAsyncTestZoneSpec == null) {
|
|
446
|
-
throw new Error('The code should be running in the fakeAsync zone to call this function');
|
|
447
|
-
}
|
|
448
|
-
return _fakeAsyncTestZoneSpec;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
|
|
452
|
-
*
|
|
453
|
-
* The microtasks queue is drained at the very start of this function and after any timer callback
|
|
454
|
-
* has been executed.
|
|
455
|
-
*
|
|
456
|
-
* @usageNotes
|
|
457
|
-
* ### Example
|
|
458
|
-
*
|
|
459
|
-
* {@example core/testing/ts/fake_async.ts region='basic'}
|
|
460
|
-
*
|
|
461
|
-
* @publicApi
|
|
462
|
-
*/
|
|
463
|
-
function tickFallback(millis = 0, tickOptions = {
|
|
464
|
-
processNewMacroTasksSynchronously: true
|
|
465
|
-
}) {
|
|
466
|
-
_getFakeAsyncZoneSpec().tick(millis, null, tickOptions);
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
|
|
470
|
-
* draining the macrotask queue until it is empty. The returned value is the milliseconds
|
|
471
|
-
* of time that would have been elapsed.
|
|
472
|
-
*
|
|
473
|
-
* @param maxTurns
|
|
474
|
-
* @returns The simulated time elapsed, in millis.
|
|
475
|
-
*
|
|
476
|
-
* @publicApi
|
|
477
|
-
*/
|
|
478
|
-
function flushFallback(maxTurns) {
|
|
479
|
-
return _getFakeAsyncZoneSpec().flush(maxTurns);
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Discard all remaining periodic tasks.
|
|
483
|
-
*
|
|
484
|
-
* @publicApi
|
|
485
|
-
*/
|
|
486
|
-
function discardPeriodicTasksFallback() {
|
|
487
|
-
const zoneSpec = _getFakeAsyncZoneSpec();
|
|
488
|
-
zoneSpec.pendingPeriodicTimers.length = 0;
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Flush any pending microtasks.
|
|
492
|
-
*
|
|
493
|
-
* @publicApi
|
|
494
|
-
*/
|
|
495
|
-
function flushMicrotasksFallback() {
|
|
496
|
-
_getFakeAsyncZoneSpec().flushMicrotasks();
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* @license
|
|
501
|
-
* Copyright Google LLC All Rights Reserved.
|
|
502
|
-
*
|
|
503
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
504
|
-
* found in the LICENSE file at https://angular.io/license
|
|
505
|
-
*/
|
|
506
|
-
const _Zone$1 = typeof Zone !== 'undefined' ? Zone : null;
|
|
507
|
-
const fakeAsyncTestModule = _Zone$1 && _Zone$1[_Zone$1.__symbol__('fakeAsyncTest')];
|
|
260
|
+
const fakeAsyncTestModule = _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')];
|
|
261
|
+
const fakeAsyncTestModuleNotLoadedErrorMessage = `zone-testing.js is needed for the async() test helper but could not be found.
|
|
262
|
+
Please make sure that your environment includes zone.js/dist/zone-testing.js`;
|
|
508
263
|
/**
|
|
509
264
|
* Clears out the shared fake async zone for a test.
|
|
510
265
|
* To be called in a global `beforeEach`.
|
|
@@ -515,9 +270,7 @@ function resetFakeAsyncZone() {
|
|
|
515
270
|
if (fakeAsyncTestModule) {
|
|
516
271
|
return fakeAsyncTestModule.resetFakeAsyncZone();
|
|
517
272
|
}
|
|
518
|
-
|
|
519
|
-
return resetFakeAsyncZoneFallback();
|
|
520
|
-
}
|
|
273
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
521
274
|
}
|
|
522
275
|
/**
|
|
523
276
|
* Wraps a function to be executed in the fakeAsync zone:
|
|
@@ -542,9 +295,7 @@ function fakeAsync(fn) {
|
|
|
542
295
|
if (fakeAsyncTestModule) {
|
|
543
296
|
return fakeAsyncTestModule.fakeAsync(fn);
|
|
544
297
|
}
|
|
545
|
-
|
|
546
|
-
return fakeAsyncFallback(fn);
|
|
547
|
-
}
|
|
298
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
548
299
|
}
|
|
549
300
|
/**
|
|
550
301
|
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
|
|
@@ -603,9 +354,7 @@ function tick(millis = 0, tickOptions = {
|
|
|
603
354
|
if (fakeAsyncTestModule) {
|
|
604
355
|
return fakeAsyncTestModule.tick(millis, tickOptions);
|
|
605
356
|
}
|
|
606
|
-
|
|
607
|
-
return tickFallback(millis, tickOptions);
|
|
608
|
-
}
|
|
357
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
609
358
|
}
|
|
610
359
|
/**
|
|
611
360
|
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
|
|
@@ -621,9 +370,7 @@ function flush(maxTurns) {
|
|
|
621
370
|
if (fakeAsyncTestModule) {
|
|
622
371
|
return fakeAsyncTestModule.flush(maxTurns);
|
|
623
372
|
}
|
|
624
|
-
|
|
625
|
-
return flushFallback(maxTurns);
|
|
626
|
-
}
|
|
373
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
627
374
|
}
|
|
628
375
|
/**
|
|
629
376
|
* Discard all remaining periodic tasks.
|
|
@@ -634,9 +381,7 @@ function discardPeriodicTasks() {
|
|
|
634
381
|
if (fakeAsyncTestModule) {
|
|
635
382
|
return fakeAsyncTestModule.discardPeriodicTasks();
|
|
636
383
|
}
|
|
637
|
-
|
|
638
|
-
discardPeriodicTasksFallback();
|
|
639
|
-
}
|
|
384
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
640
385
|
}
|
|
641
386
|
/**
|
|
642
387
|
* Flush any pending microtasks.
|
|
@@ -647,9 +392,7 @@ function flushMicrotasks() {
|
|
|
647
392
|
if (fakeAsyncTestModule) {
|
|
648
393
|
return fakeAsyncTestModule.flushMicrotasks();
|
|
649
394
|
}
|
|
650
|
-
|
|
651
|
-
return flushMicrotasksFallback();
|
|
652
|
-
}
|
|
395
|
+
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
653
396
|
}
|
|
654
397
|
|
|
655
398
|
/**
|
|
@@ -2671,10 +2414,10 @@ function withModule(moduleDef, fn) {
|
|
|
2671
2414
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2672
2415
|
* found in the LICENSE file at https://angular.io/license
|
|
2673
2416
|
*/
|
|
2674
|
-
const _global
|
|
2417
|
+
const _global = (typeof window === 'undefined' ? global : window);
|
|
2675
2418
|
// Reset the test providers and the fake async zone before each test.
|
|
2676
|
-
if (_global
|
|
2677
|
-
_global
|
|
2419
|
+
if (_global.beforeEach) {
|
|
2420
|
+
_global.beforeEach(() => {
|
|
2678
2421
|
TestBed.resetTestingModule();
|
|
2679
2422
|
resetFakeAsyncZone();
|
|
2680
2423
|
});
|