@angular/core 14.1.3 → 14.2.0-rc.0
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/esm2020/src/application_ref.mjs +26 -21
- package/esm2020/src/core_private_export.mjs +3 -3
- package/esm2020/src/core_render3_private_export.mjs +4 -4
- package/esm2020/src/di/interface/defs.mjs +4 -1
- package/esm2020/src/render3/component_ref.mjs +4 -31
- package/esm2020/src/render3/definition.mjs +5 -1
- package/esm2020/src/render3/index.mjs +4 -4
- package/esm2020/src/render3/instructions/change_detection.mjs +3 -19
- package/esm2020/src/render3/instructions/shared.mjs +1 -43
- package/esm2020/src/render3/interfaces/view.mjs +1 -1
- package/esm2020/src/render3/jit/module.mjs +2 -6
- package/esm2020/src/render3/util/change_detection_utils.mjs +7 -3
- package/esm2020/src/render3/util/misc_utils.mjs +1 -7
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/esm2020/testing/src/resolvers.mjs +1 -1
- package/esm2020/testing/src/test_bed.mjs +442 -15
- package/esm2020/testing/src/test_bed_common.mjs +1 -1
- package/esm2020/testing/src/test_bed_compiler.mjs +823 -0
- package/esm2020/testing/src/test_hooks.mjs +5 -5
- package/esm2020/testing/src/testing.mjs +1 -1
- package/fesm2015/core.mjs +38 -116
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +114 -202
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +38 -116
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +114 -203
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +13 -100
- package/package.json +1 -1
- package/testing/index.d.ts +18 -94
- package/esm2020/src/render3/interfaces/player.mjs +0 -9
- package/esm2020/testing/src/r3_test_bed.mjs +0 -433
- package/esm2020/testing/src/r3_test_bed_compiler.mjs +0 -823
package/fesm2020/testing.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.
|
|
2
|
+
* @license Angular v14.2.0-rc.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ModuleWithComponentFactories,
|
|
7
|
+
import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, InjectionToken as InjectionToken$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ModuleWithComponentFactories, Injector as Injector$1, InjectFlags as InjectFlags$1, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode as ɵsetUnknownElementStrictMode$1, ɵsetUnknownPropertyStrictMode as ɵsetUnknownPropertyStrictMode$1, ɵgetUnknownElementStrictMode as ɵgetUnknownElementStrictMode$1, ɵgetUnknownPropertyStrictMode as ɵgetUnknownPropertyStrictMode$1, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
8
8
|
import { ResourceLoader } from '@angular/compiler';
|
|
9
9
|
import { Subject, Subscription } from 'rxjs';
|
|
10
10
|
|
|
@@ -413,6 +413,37 @@ function flushMicrotasks() {
|
|
|
413
413
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
/**
|
|
417
|
+
* @license
|
|
418
|
+
* Copyright Google LLC All Rights Reserved.
|
|
419
|
+
*
|
|
420
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
421
|
+
* found in the LICENSE file at https://angular.io/license
|
|
422
|
+
*/
|
|
423
|
+
/** Whether test modules should be torn down by default. */
|
|
424
|
+
const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
|
|
425
|
+
/** Whether unknown elements in templates should throw by default. */
|
|
426
|
+
const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
|
|
427
|
+
/** Whether unknown properties in templates should throw by default. */
|
|
428
|
+
const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
|
|
429
|
+
/**
|
|
430
|
+
* An abstract class for inserting the root test component element in a platform independent way.
|
|
431
|
+
*
|
|
432
|
+
* @publicApi
|
|
433
|
+
*/
|
|
434
|
+
class TestComponentRenderer {
|
|
435
|
+
insertRootElement(rootElementId) { }
|
|
436
|
+
removeAllRootElements() { }
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* @publicApi
|
|
440
|
+
*/
|
|
441
|
+
const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
|
|
442
|
+
/**
|
|
443
|
+
* @publicApi
|
|
444
|
+
*/
|
|
445
|
+
const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
|
|
446
|
+
|
|
416
447
|
/**
|
|
417
448
|
* @license
|
|
418
449
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -803,6 +834,9 @@ function ɵɵdefineInjector(options) {
|
|
|
803
834
|
function getInjectableDef(type) {
|
|
804
835
|
return getOwnDefinition(type, NG_PROV_DEF) || getOwnDefinition(type, NG_INJECTABLE_DEF);
|
|
805
836
|
}
|
|
837
|
+
function isInjectable(type) {
|
|
838
|
+
return getInjectableDef(type) !== null;
|
|
839
|
+
}
|
|
806
840
|
/**
|
|
807
841
|
* Return definition only if it is defined directly on `type` and is not inherited from a base
|
|
808
842
|
* class of `type`.
|
|
@@ -2741,6 +2775,10 @@ function getDirectiveDef(type) {
|
|
|
2741
2775
|
function getPipeDef$1(type) {
|
|
2742
2776
|
return type[NG_PIPE_DEF] || null;
|
|
2743
2777
|
}
|
|
2778
|
+
function isStandalone(type) {
|
|
2779
|
+
const def = getComponentDef$1(type) || getDirectiveDef(type) || getPipeDef$1(type);
|
|
2780
|
+
return def !== null ? def.standalone : false;
|
|
2781
|
+
}
|
|
2744
2782
|
function getNgModuleDef(type, throwNotFound) {
|
|
2745
2783
|
const ngModuleDef = type[NG_MOD_DEF] || null;
|
|
2746
2784
|
if (!ngModuleDef && throwNotFound === true) {
|
|
@@ -5473,11 +5511,6 @@ function setAllowDuplicateNgModuleIdsForTest(allowDuplicates) {
|
|
|
5473
5511
|
* Use of this source code is governed by an MIT-style license that can be
|
|
5474
5512
|
* found in the LICENSE file at https://angular.io/license
|
|
5475
5513
|
*/
|
|
5476
|
-
const defaultScheduler = (() => (typeof requestAnimationFrame !== 'undefined' &&
|
|
5477
|
-
requestAnimationFrame || // browser only
|
|
5478
|
-
setTimeout // everything else
|
|
5479
|
-
)
|
|
5480
|
-
.bind(_global$1))();
|
|
5481
5514
|
/**
|
|
5482
5515
|
*
|
|
5483
5516
|
* @codeGenApi
|
|
@@ -7614,7 +7647,7 @@ class Version {
|
|
|
7614
7647
|
/**
|
|
7615
7648
|
* @publicApi
|
|
7616
7649
|
*/
|
|
7617
|
-
const VERSION = new Version('14.
|
|
7650
|
+
const VERSION = new Version('14.2.0-rc.0');
|
|
7618
7651
|
|
|
7619
7652
|
/**
|
|
7620
7653
|
* @license
|
|
@@ -12010,11 +12043,6 @@ class LContainerDebug {
|
|
|
12010
12043
|
* Use of this source code is governed by an MIT-style license that can be
|
|
12011
12044
|
* found in the LICENSE file at https://angular.io/license
|
|
12012
12045
|
*/
|
|
12013
|
-
/**
|
|
12014
|
-
* A permanent marker promise which signifies that the current CD tree is
|
|
12015
|
-
* clean.
|
|
12016
|
-
*/
|
|
12017
|
-
const _CLEAN_PROMISE = (() => Promise.resolve(null))();
|
|
12018
12046
|
/**
|
|
12019
12047
|
* Invoke `HostBindingsFunction`s for view.
|
|
12020
12048
|
*
|
|
@@ -13512,42 +13540,6 @@ function markViewDirty(lView) {
|
|
|
13512
13540
|
}
|
|
13513
13541
|
return null;
|
|
13514
13542
|
}
|
|
13515
|
-
/**
|
|
13516
|
-
* Used to schedule change detection on the whole application.
|
|
13517
|
-
*
|
|
13518
|
-
* Unlike `tick`, `scheduleTick` coalesces multiple calls into one change detection run.
|
|
13519
|
-
* It is usually called indirectly by calling `markDirty` when the view needs to be
|
|
13520
|
-
* re-rendered.
|
|
13521
|
-
*
|
|
13522
|
-
* Typically `scheduleTick` uses `requestAnimationFrame` to coalesce multiple
|
|
13523
|
-
* `scheduleTick` requests. The scheduling function can be overridden in
|
|
13524
|
-
* `renderComponent`'s `scheduler` option.
|
|
13525
|
-
*/
|
|
13526
|
-
function scheduleTick(rootContext, flags) {
|
|
13527
|
-
const nothingScheduled = rootContext.flags === 0 /* RootContextFlags.Empty */;
|
|
13528
|
-
if (nothingScheduled && rootContext.clean == _CLEAN_PROMISE) {
|
|
13529
|
-
// https://github.com/angular/angular/issues/39296
|
|
13530
|
-
// should only attach the flags when really scheduling a tick
|
|
13531
|
-
rootContext.flags |= flags;
|
|
13532
|
-
let res;
|
|
13533
|
-
rootContext.clean = new Promise((r) => res = r);
|
|
13534
|
-
rootContext.scheduler(() => {
|
|
13535
|
-
if (rootContext.flags & 1 /* RootContextFlags.DetectChanges */) {
|
|
13536
|
-
rootContext.flags &= ~1 /* RootContextFlags.DetectChanges */;
|
|
13537
|
-
tickRootContext(rootContext);
|
|
13538
|
-
}
|
|
13539
|
-
if (rootContext.flags & 2 /* RootContextFlags.FlushPlayers */) {
|
|
13540
|
-
rootContext.flags &= ~2 /* RootContextFlags.FlushPlayers */;
|
|
13541
|
-
const playerHandler = rootContext.playerHandler;
|
|
13542
|
-
if (playerHandler) {
|
|
13543
|
-
playerHandler.flushPlayers();
|
|
13544
|
-
}
|
|
13545
|
-
}
|
|
13546
|
-
rootContext.clean = _CLEAN_PROMISE;
|
|
13547
|
-
res(null);
|
|
13548
|
-
});
|
|
13549
|
-
}
|
|
13550
|
-
}
|
|
13551
13543
|
function tickRootContext(rootContext) {
|
|
13552
13544
|
for (let i = 0; i < rootContext.components.length; i++) {
|
|
13553
13545
|
const rootComponent = rootContext.components[i];
|
|
@@ -13656,7 +13648,6 @@ function storePropertyBindingMetadata(tData, tNode, propertyName, bindingIndex,
|
|
|
13656
13648
|
}
|
|
13657
13649
|
}
|
|
13658
13650
|
}
|
|
13659
|
-
const CLEAN_PROMISE = _CLEAN_PROMISE;
|
|
13660
13651
|
function getOrCreateLViewCleanup(view) {
|
|
13661
13652
|
// top level variables should not be exported for performance reasons (PERF_NOTES.md)
|
|
13662
13653
|
return view[CLEANUP] || (view[CLEANUP] = ngDevMode ? new LCleanup() : []);
|
|
@@ -14415,14 +14406,8 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
|
|
|
14415
14406
|
}
|
|
14416
14407
|
return component;
|
|
14417
14408
|
}
|
|
14418
|
-
function createRootContext(
|
|
14419
|
-
return {
|
|
14420
|
-
components: [],
|
|
14421
|
-
scheduler: scheduler || defaultScheduler,
|
|
14422
|
-
clean: CLEAN_PROMISE,
|
|
14423
|
-
playerHandler: playerHandler || null,
|
|
14424
|
-
flags: 0 /* RootContextFlags.Empty */
|
|
14425
|
-
};
|
|
14409
|
+
function createRootContext() {
|
|
14410
|
+
return { components: [] };
|
|
14426
14411
|
}
|
|
14427
14412
|
/**
|
|
14428
14413
|
* Used to enable lifecycle hooks on the root component.
|
|
@@ -14442,25 +14427,6 @@ function LifecycleHooksFeature() {
|
|
|
14442
14427
|
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
14443
14428
|
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
14444
14429
|
}
|
|
14445
|
-
/**
|
|
14446
|
-
* Wait on component until it is rendered.
|
|
14447
|
-
*
|
|
14448
|
-
* This function returns a `Promise` which is resolved when the component's
|
|
14449
|
-
* change detection is executed. This is determined by finding the scheduler
|
|
14450
|
-
* associated with the `component`'s render tree and waiting until the scheduler
|
|
14451
|
-
* flushes. If nothing is scheduled, the function returns a resolved promise.
|
|
14452
|
-
*
|
|
14453
|
-
* Example:
|
|
14454
|
-
* ```
|
|
14455
|
-
* await whenRendered(myComponent);
|
|
14456
|
-
* ```
|
|
14457
|
-
*
|
|
14458
|
-
* @param component Component to wait upon
|
|
14459
|
-
* @returns Promise which resolves when the component is rendered.
|
|
14460
|
-
*/
|
|
14461
|
-
function whenRendered(component) {
|
|
14462
|
-
return getRootContext(component).clean;
|
|
14463
|
-
}
|
|
14464
14430
|
|
|
14465
14431
|
/**
|
|
14466
14432
|
* @license
|
|
@@ -15445,21 +15411,6 @@ function detectChanges(component) {
|
|
|
15445
15411
|
const view = getComponentViewByInstance(component);
|
|
15446
15412
|
detectChangesInternal(view[TVIEW], view, component);
|
|
15447
15413
|
}
|
|
15448
|
-
/**
|
|
15449
|
-
* Marks the component as dirty (needing change detection). Marking a component dirty will
|
|
15450
|
-
* schedule a change detection on it at some point in the future.
|
|
15451
|
-
*
|
|
15452
|
-
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
15453
|
-
* detection can be scheduled per component tree.
|
|
15454
|
-
*
|
|
15455
|
-
* @param component Component to mark as dirty.
|
|
15456
|
-
*/
|
|
15457
|
-
function markDirty(component) {
|
|
15458
|
-
ngDevMode && assertDefined(component, 'component');
|
|
15459
|
-
const rootView = markViewDirty(getComponentViewByInstance(component));
|
|
15460
|
-
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
|
|
15461
|
-
scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
|
|
15462
|
-
}
|
|
15463
15414
|
|
|
15464
15415
|
/**
|
|
15465
15416
|
* @license
|
|
@@ -24621,10 +24572,6 @@ function compileNgModuleDefs(moduleType, ngModule, allowDuplicateDeclarationsInR
|
|
|
24621
24572
|
configurable: !!ngDevMode,
|
|
24622
24573
|
});
|
|
24623
24574
|
}
|
|
24624
|
-
function isStandalone(type) {
|
|
24625
|
-
const def = getComponentDef$1(type) || getDirectiveDef(type) || getPipeDef$1(type);
|
|
24626
|
-
return def !== null ? def.standalone : false;
|
|
24627
|
-
}
|
|
24628
24575
|
function generateStandaloneInDeclarationsError(type, location) {
|
|
24629
24576
|
const prefix = `Unexpected "${stringifyForError(type)}" found in the "declarations" array of the`;
|
|
24630
24577
|
const suffix = `"${stringifyForError(type)}" is marked as standalone and can't be declared ` +
|
|
@@ -25235,7 +25182,7 @@ function assertNoStandaloneComponents(types, resolver, location) {
|
|
|
25235
25182
|
}
|
|
25236
25183
|
});
|
|
25237
25184
|
}
|
|
25238
|
-
class
|
|
25185
|
+
class TestBedCompiler {
|
|
25239
25186
|
constructor(platform, additionalModuleTypes) {
|
|
25240
25187
|
this.platform = platform;
|
|
25241
25188
|
this.additionalModuleTypes = additionalModuleTypes;
|
|
@@ -26036,49 +25983,23 @@ class R3TestCompiler {
|
|
|
26036
25983
|
* Use of this source code is governed by an MIT-style license that can be
|
|
26037
25984
|
* found in the LICENSE file at https://angular.io/license
|
|
26038
25985
|
*/
|
|
26039
|
-
|
|
26040
|
-
const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
|
|
26041
|
-
/** Whether unknown elements in templates should throw by default. */
|
|
26042
|
-
const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
|
|
26043
|
-
/** Whether unknown properties in templates should throw by default. */
|
|
26044
|
-
const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
|
|
25986
|
+
let _nextRootElementId = 0;
|
|
26045
25987
|
/**
|
|
26046
|
-
*
|
|
25988
|
+
* Returns a singleton of the `TestBed` class.
|
|
26047
25989
|
*
|
|
26048
25990
|
* @publicApi
|
|
26049
25991
|
*/
|
|
26050
|
-
|
|
26051
|
-
|
|
26052
|
-
removeAllRootElements() { }
|
|
25992
|
+
function getTestBed() {
|
|
25993
|
+
return TestBedImpl.INSTANCE;
|
|
26053
25994
|
}
|
|
26054
|
-
/**
|
|
26055
|
-
* @publicApi
|
|
26056
|
-
*/
|
|
26057
|
-
const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
|
|
26058
|
-
/**
|
|
26059
|
-
* @publicApi
|
|
26060
|
-
*/
|
|
26061
|
-
const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
|
|
26062
|
-
|
|
26063
|
-
/**
|
|
26064
|
-
* @license
|
|
26065
|
-
* Copyright Google LLC All Rights Reserved.
|
|
26066
|
-
*
|
|
26067
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
26068
|
-
* found in the LICENSE file at https://angular.io/license
|
|
26069
|
-
*/
|
|
26070
|
-
let _nextRootElementId = 0;
|
|
26071
25995
|
/**
|
|
26072
25996
|
* @description
|
|
26073
25997
|
* Configures and initializes environment for unit testing and provides methods for
|
|
26074
25998
|
* creating components and services in unit tests.
|
|
26075
25999
|
*
|
|
26076
26000
|
* TestBed is the primary api for writing unit tests for Angular applications and libraries.
|
|
26077
|
-
*
|
|
26078
|
-
* Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
|
|
26079
|
-
* according to the compiler used.
|
|
26080
26001
|
*/
|
|
26081
|
-
class
|
|
26002
|
+
class TestBedImpl {
|
|
26082
26003
|
constructor() {
|
|
26083
26004
|
// Properties
|
|
26084
26005
|
this.platform = null;
|
|
@@ -26086,7 +26007,15 @@ class TestBedRender3 {
|
|
|
26086
26007
|
this._compiler = null;
|
|
26087
26008
|
this._testModuleRef = null;
|
|
26088
26009
|
this._activeFixtures = [];
|
|
26089
|
-
|
|
26010
|
+
/**
|
|
26011
|
+
* Internal-only flag to indicate whether a module
|
|
26012
|
+
* scoping queue has been checked and flushed already.
|
|
26013
|
+
* @nodoc
|
|
26014
|
+
*/
|
|
26015
|
+
this.globalCompilationChecked = false;
|
|
26016
|
+
}
|
|
26017
|
+
static get INSTANCE() {
|
|
26018
|
+
return TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl();
|
|
26090
26019
|
}
|
|
26091
26020
|
/**
|
|
26092
26021
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
@@ -26102,7 +26031,7 @@ class TestBedRender3 {
|
|
|
26102
26031
|
* @publicApi
|
|
26103
26032
|
*/
|
|
26104
26033
|
static initTestEnvironment(ngModule, platform, options) {
|
|
26105
|
-
const testBed =
|
|
26034
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26106
26035
|
testBed.initTestEnvironment(ngModule, platform, options);
|
|
26107
26036
|
return testBed;
|
|
26108
26037
|
}
|
|
@@ -26112,19 +26041,17 @@ class TestBedRender3 {
|
|
|
26112
26041
|
* @publicApi
|
|
26113
26042
|
*/
|
|
26114
26043
|
static resetTestEnvironment() {
|
|
26115
|
-
|
|
26044
|
+
TestBedImpl.INSTANCE.resetTestEnvironment();
|
|
26116
26045
|
}
|
|
26117
26046
|
static configureCompiler(config) {
|
|
26118
|
-
|
|
26119
|
-
return TestBedRender3;
|
|
26047
|
+
return TestBedImpl.INSTANCE.configureCompiler(config);
|
|
26120
26048
|
}
|
|
26121
26049
|
/**
|
|
26122
26050
|
* Allows overriding default providers, directives, pipes, modules of the test injector,
|
|
26123
26051
|
* which are defined in test_injector.js
|
|
26124
26052
|
*/
|
|
26125
26053
|
static configureTestingModule(moduleDef) {
|
|
26126
|
-
|
|
26127
|
-
return TestBedRender3;
|
|
26054
|
+
return TestBedImpl.INSTANCE.configureTestingModule(moduleDef);
|
|
26128
26055
|
}
|
|
26129
26056
|
/**
|
|
26130
26057
|
* Compile components with a `templateUrl` for the test's NgModule.
|
|
@@ -26132,27 +26059,22 @@ class TestBedRender3 {
|
|
|
26132
26059
|
* as fetching urls is asynchronous.
|
|
26133
26060
|
*/
|
|
26134
26061
|
static compileComponents() {
|
|
26135
|
-
return
|
|
26062
|
+
return TestBedImpl.INSTANCE.compileComponents();
|
|
26136
26063
|
}
|
|
26137
26064
|
static overrideModule(ngModule, override) {
|
|
26138
|
-
|
|
26139
|
-
return TestBedRender3;
|
|
26065
|
+
return TestBedImpl.INSTANCE.overrideModule(ngModule, override);
|
|
26140
26066
|
}
|
|
26141
26067
|
static overrideComponent(component, override) {
|
|
26142
|
-
|
|
26143
|
-
return TestBedRender3;
|
|
26068
|
+
return TestBedImpl.INSTANCE.overrideComponent(component, override);
|
|
26144
26069
|
}
|
|
26145
26070
|
static overrideDirective(directive, override) {
|
|
26146
|
-
|
|
26147
|
-
return TestBedRender3;
|
|
26071
|
+
return TestBedImpl.INSTANCE.overrideDirective(directive, override);
|
|
26148
26072
|
}
|
|
26149
26073
|
static overridePipe(pipe, override) {
|
|
26150
|
-
|
|
26151
|
-
return TestBedRender3;
|
|
26074
|
+
return TestBedImpl.INSTANCE.overridePipe(pipe, override);
|
|
26152
26075
|
}
|
|
26153
26076
|
static overrideTemplate(component, template) {
|
|
26154
|
-
|
|
26155
|
-
return TestBedRender3;
|
|
26077
|
+
return TestBedImpl.INSTANCE.overrideTemplate(component, template);
|
|
26156
26078
|
}
|
|
26157
26079
|
/**
|
|
26158
26080
|
* Overrides the template of the given component, compiling the template
|
|
@@ -26161,32 +26083,32 @@ class TestBedRender3 {
|
|
|
26161
26083
|
* Note: This works for JIT and AOTed components as well.
|
|
26162
26084
|
*/
|
|
26163
26085
|
static overrideTemplateUsingTestingModule(component, template) {
|
|
26164
|
-
|
|
26165
|
-
return TestBedRender3;
|
|
26086
|
+
return TestBedImpl.INSTANCE.overrideTemplateUsingTestingModule(component, template);
|
|
26166
26087
|
}
|
|
26167
26088
|
static overrideProvider(token, provider) {
|
|
26168
|
-
|
|
26169
|
-
return TestBedRender3;
|
|
26089
|
+
return TestBedImpl.INSTANCE.overrideProvider(token, provider);
|
|
26170
26090
|
}
|
|
26171
26091
|
static inject(token, notFoundValue, flags) {
|
|
26172
|
-
return
|
|
26092
|
+
return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
|
|
26173
26093
|
}
|
|
26174
26094
|
/** @deprecated from v9.0.0 use TestBed.inject */
|
|
26175
26095
|
static get(token, notFoundValue = Injector$1.THROW_IF_NOT_FOUND, flags = InjectFlags$1.Default) {
|
|
26176
|
-
return
|
|
26096
|
+
return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
|
|
26177
26097
|
}
|
|
26178
26098
|
static createComponent(component) {
|
|
26179
|
-
return
|
|
26099
|
+
return TestBedImpl.INSTANCE.createComponent(component);
|
|
26180
26100
|
}
|
|
26181
26101
|
static resetTestingModule() {
|
|
26182
|
-
|
|
26183
|
-
return TestBedRender3;
|
|
26102
|
+
return TestBedImpl.INSTANCE.resetTestingModule();
|
|
26184
26103
|
}
|
|
26185
|
-
static
|
|
26186
|
-
return
|
|
26104
|
+
static execute(tokens, fn, context) {
|
|
26105
|
+
return TestBedImpl.INSTANCE.execute(tokens, fn, context);
|
|
26187
26106
|
}
|
|
26188
|
-
static
|
|
26189
|
-
|
|
26107
|
+
static get platform() {
|
|
26108
|
+
return TestBedImpl.INSTANCE.platform;
|
|
26109
|
+
}
|
|
26110
|
+
static get ngModule() {
|
|
26111
|
+
return TestBedImpl.INSTANCE.ngModule;
|
|
26190
26112
|
}
|
|
26191
26113
|
/**
|
|
26192
26114
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
@@ -26205,12 +26127,12 @@ class TestBedRender3 {
|
|
|
26205
26127
|
if (this.platform || this.ngModule) {
|
|
26206
26128
|
throw new Error('Cannot set base providers because it has already been called');
|
|
26207
26129
|
}
|
|
26208
|
-
|
|
26209
|
-
|
|
26210
|
-
|
|
26130
|
+
TestBedImpl._environmentTeardownOptions = options?.teardown;
|
|
26131
|
+
TestBedImpl._environmentErrorOnUnknownElementsOption = options?.errorOnUnknownElements;
|
|
26132
|
+
TestBedImpl._environmentErrorOnUnknownPropertiesOption = options?.errorOnUnknownProperties;
|
|
26211
26133
|
this.platform = platform;
|
|
26212
26134
|
this.ngModule = ngModule;
|
|
26213
|
-
this._compiler = new
|
|
26135
|
+
this._compiler = new TestBedCompiler(this.platform, this.ngModule);
|
|
26214
26136
|
// TestBed does not have an API which can reliably detect the start of a test, and thus could be
|
|
26215
26137
|
// used to track the state of the NgModule registry and reset it correctly. Instead, when we
|
|
26216
26138
|
// know we're in a testing scenario, we disable the check for duplicate NgModule registration
|
|
@@ -26227,7 +26149,7 @@ class TestBedRender3 {
|
|
|
26227
26149
|
this._compiler = null;
|
|
26228
26150
|
this.platform = null;
|
|
26229
26151
|
this.ngModule = null;
|
|
26230
|
-
|
|
26152
|
+
TestBedImpl._environmentTeardownOptions = undefined;
|
|
26231
26153
|
ɵsetAllowDuplicateNgModuleIdsForTest(false);
|
|
26232
26154
|
}
|
|
26233
26155
|
resetTestingModule() {
|
|
@@ -26236,7 +26158,7 @@ class TestBedRender3 {
|
|
|
26236
26158
|
if (this._compiler !== null) {
|
|
26237
26159
|
this.compiler.restoreOriginalState();
|
|
26238
26160
|
}
|
|
26239
|
-
this._compiler = new
|
|
26161
|
+
this._compiler = new TestBedCompiler(this.platform, this.ngModule);
|
|
26240
26162
|
// Restore the previous value of the "error on unknown elements" option
|
|
26241
26163
|
ɵsetUnknownElementStrictMode$1(this._previousErrorOnUnknownElementsOption ?? THROW_ON_UNKNOWN_ELEMENTS_DEFAULT);
|
|
26242
26164
|
// Restore the previous value of the "error on unknown properties" option
|
|
@@ -26260,6 +26182,7 @@ class TestBedRender3 {
|
|
|
26260
26182
|
this._instanceErrorOnUnknownPropertiesOption = undefined;
|
|
26261
26183
|
}
|
|
26262
26184
|
}
|
|
26185
|
+
return this;
|
|
26263
26186
|
}
|
|
26264
26187
|
configureCompiler(config) {
|
|
26265
26188
|
if (config.useJit != null) {
|
|
@@ -26268,6 +26191,7 @@ class TestBedRender3 {
|
|
|
26268
26191
|
if (config.providers !== undefined) {
|
|
26269
26192
|
this.compiler.setCompilerProviders(config.providers);
|
|
26270
26193
|
}
|
|
26194
|
+
return this;
|
|
26271
26195
|
}
|
|
26272
26196
|
configureTestingModule(moduleDef) {
|
|
26273
26197
|
this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
|
|
@@ -26288,12 +26212,13 @@ class TestBedRender3 {
|
|
|
26288
26212
|
this._previousErrorOnUnknownPropertiesOption = ɵgetUnknownPropertyStrictMode$1();
|
|
26289
26213
|
ɵsetUnknownPropertyStrictMode$1(this.shouldThrowErrorOnUnknownProperties());
|
|
26290
26214
|
this.compiler.configureTestingModule(moduleDef);
|
|
26215
|
+
return this;
|
|
26291
26216
|
}
|
|
26292
26217
|
compileComponents() {
|
|
26293
26218
|
return this.compiler.compileComponents();
|
|
26294
26219
|
}
|
|
26295
26220
|
inject(token, notFoundValue, flags) {
|
|
26296
|
-
if (token ===
|
|
26221
|
+
if (token === TestBed) {
|
|
26297
26222
|
return this;
|
|
26298
26223
|
}
|
|
26299
26224
|
const UNDEFINED = {};
|
|
@@ -26312,22 +26237,27 @@ class TestBedRender3 {
|
|
|
26312
26237
|
overrideModule(ngModule, override) {
|
|
26313
26238
|
this.assertNotInstantiated('overrideModule', 'override module metadata');
|
|
26314
26239
|
this.compiler.overrideModule(ngModule, override);
|
|
26240
|
+
return this;
|
|
26315
26241
|
}
|
|
26316
26242
|
overrideComponent(component, override) {
|
|
26317
26243
|
this.assertNotInstantiated('overrideComponent', 'override component metadata');
|
|
26318
26244
|
this.compiler.overrideComponent(component, override);
|
|
26245
|
+
return this;
|
|
26319
26246
|
}
|
|
26320
26247
|
overrideTemplateUsingTestingModule(component, template) {
|
|
26321
26248
|
this.assertNotInstantiated('R3TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
|
|
26322
26249
|
this.compiler.overrideTemplateUsingTestingModule(component, template);
|
|
26250
|
+
return this;
|
|
26323
26251
|
}
|
|
26324
26252
|
overrideDirective(directive, override) {
|
|
26325
26253
|
this.assertNotInstantiated('overrideDirective', 'override directive metadata');
|
|
26326
26254
|
this.compiler.overrideDirective(directive, override);
|
|
26255
|
+
return this;
|
|
26327
26256
|
}
|
|
26328
26257
|
overridePipe(pipe, override) {
|
|
26329
26258
|
this.assertNotInstantiated('overridePipe', 'override pipe metadata');
|
|
26330
26259
|
this.compiler.overridePipe(pipe, override);
|
|
26260
|
+
return this;
|
|
26331
26261
|
}
|
|
26332
26262
|
/**
|
|
26333
26263
|
* Overwrites all providers for the given token with the given provider definition.
|
|
@@ -26335,6 +26265,10 @@ class TestBedRender3 {
|
|
|
26335
26265
|
overrideProvider(token, provider) {
|
|
26336
26266
|
this.assertNotInstantiated('overrideProvider', 'override provider');
|
|
26337
26267
|
this.compiler.overrideProvider(token, provider);
|
|
26268
|
+
return this;
|
|
26269
|
+
}
|
|
26270
|
+
overrideTemplate(component, template) {
|
|
26271
|
+
return this.overrideComponent(component, { set: { template, templateUrl: null } });
|
|
26338
26272
|
}
|
|
26339
26273
|
createComponent(type) {
|
|
26340
26274
|
const testComponentRenderer = this.inject(TestComponentRenderer);
|
|
@@ -26399,10 +26333,10 @@ class TestBedRender3 {
|
|
|
26399
26333
|
checkGlobalCompilationFinished() {
|
|
26400
26334
|
// Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
|
|
26401
26335
|
// guard that compilations queued in tests (after instantiation) are never flushed accidentally.
|
|
26402
|
-
if (!this.
|
|
26336
|
+
if (!this.globalCompilationChecked && this._testModuleRef === null) {
|
|
26403
26337
|
ɵflushModuleScopingQueueAsMuchAsPossible();
|
|
26404
26338
|
}
|
|
26405
|
-
this.
|
|
26339
|
+
this.globalCompilationChecked = true;
|
|
26406
26340
|
}
|
|
26407
26341
|
destroyActiveFixtures() {
|
|
26408
26342
|
let errorCount = 0;
|
|
@@ -26426,7 +26360,7 @@ class TestBedRender3 {
|
|
|
26426
26360
|
}
|
|
26427
26361
|
shouldRethrowTeardownErrors() {
|
|
26428
26362
|
const instanceOptions = this._instanceTeardownOptions;
|
|
26429
|
-
const environmentOptions =
|
|
26363
|
+
const environmentOptions = TestBedImpl._environmentTeardownOptions;
|
|
26430
26364
|
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
26431
26365
|
if (!instanceOptions && !environmentOptions) {
|
|
26432
26366
|
return TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
@@ -26438,18 +26372,17 @@ class TestBedRender3 {
|
|
|
26438
26372
|
shouldThrowErrorOnUnknownElements() {
|
|
26439
26373
|
// Check if a configuration has been provided to throw when an unknown element is found
|
|
26440
26374
|
return this._instanceErrorOnUnknownElementsOption ??
|
|
26441
|
-
|
|
26442
|
-
THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
|
|
26375
|
+
TestBedImpl._environmentErrorOnUnknownElementsOption ?? THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
|
|
26443
26376
|
}
|
|
26444
26377
|
shouldThrowErrorOnUnknownProperties() {
|
|
26445
26378
|
// Check if a configuration has been provided to throw when an unknown property is found
|
|
26446
26379
|
return this._instanceErrorOnUnknownPropertiesOption ??
|
|
26447
|
-
|
|
26380
|
+
TestBedImpl._environmentErrorOnUnknownPropertiesOption ??
|
|
26448
26381
|
THROW_ON_UNKNOWN_PROPERTIES_DEFAULT;
|
|
26449
26382
|
}
|
|
26450
26383
|
shouldTearDownTestingModule() {
|
|
26451
26384
|
return this._instanceTeardownOptions?.destroyAfterEach ??
|
|
26452
|
-
|
|
26385
|
+
TestBedImpl._environmentTeardownOptions?.destroyAfterEach ??
|
|
26453
26386
|
TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
26454
26387
|
}
|
|
26455
26388
|
tearDownTestingModule() {
|
|
@@ -26479,18 +26412,7 @@ class TestBedRender3 {
|
|
|
26479
26412
|
}
|
|
26480
26413
|
}
|
|
26481
26414
|
}
|
|
26482
|
-
|
|
26483
|
-
function _getTestBedRender3() {
|
|
26484
|
-
return testBed = testBed || new TestBedRender3();
|
|
26485
|
-
}
|
|
26486
|
-
|
|
26487
|
-
/**
|
|
26488
|
-
* @license
|
|
26489
|
-
* Copyright Google LLC All Rights Reserved.
|
|
26490
|
-
*
|
|
26491
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
26492
|
-
* found in the LICENSE file at https://angular.io/license
|
|
26493
|
-
*/
|
|
26415
|
+
TestBedImpl._INSTANCE = null;
|
|
26494
26416
|
/**
|
|
26495
26417
|
* @description
|
|
26496
26418
|
* Configures and initializes environment for unit testing and provides methods for
|
|
@@ -26498,20 +26420,9 @@ function _getTestBedRender3() {
|
|
|
26498
26420
|
*
|
|
26499
26421
|
* `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
|
|
26500
26422
|
*
|
|
26501
|
-
* Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
|
|
26502
|
-
* according to the compiler used.
|
|
26503
|
-
*
|
|
26504
|
-
* @publicApi
|
|
26505
|
-
*/
|
|
26506
|
-
const TestBed = TestBedRender3;
|
|
26507
|
-
/**
|
|
26508
|
-
* Returns a singleton of the applicable `TestBed`.
|
|
26509
|
-
*
|
|
26510
|
-
* It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
|
|
26511
|
-
*
|
|
26512
26423
|
* @publicApi
|
|
26513
26424
|
*/
|
|
26514
|
-
const
|
|
26425
|
+
const TestBed = TestBedImpl;
|
|
26515
26426
|
/**
|
|
26516
26427
|
* Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
|
|
26517
26428
|
* (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
|
|
@@ -26535,7 +26446,7 @@ const getTestBed = _getTestBedRender3;
|
|
|
26535
26446
|
* @publicApi
|
|
26536
26447
|
*/
|
|
26537
26448
|
function inject(tokens, fn) {
|
|
26538
|
-
const testBed =
|
|
26449
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26539
26450
|
// Not using an arrow function to preserve context passed from call site
|
|
26540
26451
|
return function () {
|
|
26541
26452
|
return testBed.execute(tokens, fn, this);
|
|
@@ -26551,7 +26462,7 @@ class InjectSetupWrapper {
|
|
|
26551
26462
|
_addModule() {
|
|
26552
26463
|
const moduleDef = this._moduleDef();
|
|
26553
26464
|
if (moduleDef) {
|
|
26554
|
-
|
|
26465
|
+
TestBedImpl.configureTestingModule(moduleDef);
|
|
26555
26466
|
}
|
|
26556
26467
|
}
|
|
26557
26468
|
inject(tokens, fn) {
|
|
@@ -26567,7 +26478,7 @@ function withModule(moduleDef, fn) {
|
|
|
26567
26478
|
if (fn) {
|
|
26568
26479
|
// Not using an arrow function to preserve context passed from call site
|
|
26569
26480
|
return function () {
|
|
26570
|
-
const testBed =
|
|
26481
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26571
26482
|
if (moduleDef) {
|
|
26572
26483
|
testBed.configureTestingModule(moduleDef);
|
|
26573
26484
|
}
|
|
@@ -26597,9 +26508,9 @@ if (_global.afterEach) {
|
|
|
26597
26508
|
}
|
|
26598
26509
|
function getCleanupHook(expectedTeardownValue) {
|
|
26599
26510
|
return () => {
|
|
26600
|
-
|
|
26601
|
-
if (
|
|
26602
|
-
|
|
26511
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26512
|
+
if (testBed.shouldTearDownTestingModule() === expectedTeardownValue) {
|
|
26513
|
+
testBed.resetTestingModule();
|
|
26603
26514
|
resetFakeAsyncZone();
|
|
26604
26515
|
}
|
|
26605
26516
|
};
|