@angular/core 14.1.1 → 14.2.0-next.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 +25 -20
- package/esm2020/src/core_private_export.mjs +2 -2
- 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/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 +27 -22
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +105 -109
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +27 -22
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +105 -110
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/package.json +1 -1
- package/testing/index.d.ts +18 -94
- package/esm2020/testing/src/r3_test_bed.mjs +0 -433
- package/esm2020/testing/src/r3_test_bed_compiler.mjs +0 -823
package/fesm2015/testing.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.
|
|
2
|
+
* @license Angular v14.2.0-next.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 { __awaiter } from 'tslib';
|
|
9
9
|
import { ResourceLoader } from '@angular/compiler';
|
|
10
10
|
import { Subject, Subscription } from 'rxjs';
|
|
@@ -414,6 +414,37 @@ function flushMicrotasks() {
|
|
|
414
414
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
/**
|
|
418
|
+
* @license
|
|
419
|
+
* Copyright Google LLC All Rights Reserved.
|
|
420
|
+
*
|
|
421
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
422
|
+
* found in the LICENSE file at https://angular.io/license
|
|
423
|
+
*/
|
|
424
|
+
/** Whether test modules should be torn down by default. */
|
|
425
|
+
const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
|
|
426
|
+
/** Whether unknown elements in templates should throw by default. */
|
|
427
|
+
const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
|
|
428
|
+
/** Whether unknown properties in templates should throw by default. */
|
|
429
|
+
const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
|
|
430
|
+
/**
|
|
431
|
+
* An abstract class for inserting the root test component element in a platform independent way.
|
|
432
|
+
*
|
|
433
|
+
* @publicApi
|
|
434
|
+
*/
|
|
435
|
+
class TestComponentRenderer {
|
|
436
|
+
insertRootElement(rootElementId) { }
|
|
437
|
+
removeAllRootElements() { }
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @publicApi
|
|
441
|
+
*/
|
|
442
|
+
const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
|
|
443
|
+
/**
|
|
444
|
+
* @publicApi
|
|
445
|
+
*/
|
|
446
|
+
const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
|
|
447
|
+
|
|
417
448
|
/**
|
|
418
449
|
* @license
|
|
419
450
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -7618,7 +7649,7 @@ class Version {
|
|
|
7618
7649
|
/**
|
|
7619
7650
|
* @publicApi
|
|
7620
7651
|
*/
|
|
7621
|
-
const VERSION = new Version('14.
|
|
7652
|
+
const VERSION = new Version('14.2.0-next.0');
|
|
7622
7653
|
|
|
7623
7654
|
/**
|
|
7624
7655
|
* @license
|
|
@@ -25233,7 +25264,7 @@ function assertNoStandaloneComponents(types, resolver, location) {
|
|
|
25233
25264
|
}
|
|
25234
25265
|
});
|
|
25235
25266
|
}
|
|
25236
|
-
class
|
|
25267
|
+
class TestBedCompiler {
|
|
25237
25268
|
constructor(platform, additionalModuleTypes) {
|
|
25238
25269
|
this.platform = platform;
|
|
25239
25270
|
this.additionalModuleTypes = additionalModuleTypes;
|
|
@@ -26046,49 +26077,23 @@ class R3TestCompiler {
|
|
|
26046
26077
|
* Use of this source code is governed by an MIT-style license that can be
|
|
26047
26078
|
* found in the LICENSE file at https://angular.io/license
|
|
26048
26079
|
*/
|
|
26049
|
-
|
|
26050
|
-
const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
|
|
26051
|
-
/** Whether unknown elements in templates should throw by default. */
|
|
26052
|
-
const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
|
|
26053
|
-
/** Whether unknown properties in templates should throw by default. */
|
|
26054
|
-
const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
|
|
26080
|
+
let _nextRootElementId = 0;
|
|
26055
26081
|
/**
|
|
26056
|
-
*
|
|
26082
|
+
* Returns a singleton of the `TestBed` class.
|
|
26057
26083
|
*
|
|
26058
26084
|
* @publicApi
|
|
26059
26085
|
*/
|
|
26060
|
-
|
|
26061
|
-
|
|
26062
|
-
removeAllRootElements() { }
|
|
26086
|
+
function getTestBed() {
|
|
26087
|
+
return TestBedImpl.INSTANCE;
|
|
26063
26088
|
}
|
|
26064
|
-
/**
|
|
26065
|
-
* @publicApi
|
|
26066
|
-
*/
|
|
26067
|
-
const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
|
|
26068
|
-
/**
|
|
26069
|
-
* @publicApi
|
|
26070
|
-
*/
|
|
26071
|
-
const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
|
|
26072
|
-
|
|
26073
|
-
/**
|
|
26074
|
-
* @license
|
|
26075
|
-
* Copyright Google LLC All Rights Reserved.
|
|
26076
|
-
*
|
|
26077
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
26078
|
-
* found in the LICENSE file at https://angular.io/license
|
|
26079
|
-
*/
|
|
26080
|
-
let _nextRootElementId = 0;
|
|
26081
26089
|
/**
|
|
26082
26090
|
* @description
|
|
26083
26091
|
* Configures and initializes environment for unit testing and provides methods for
|
|
26084
26092
|
* creating components and services in unit tests.
|
|
26085
26093
|
*
|
|
26086
26094
|
* TestBed is the primary api for writing unit tests for Angular applications and libraries.
|
|
26087
|
-
*
|
|
26088
|
-
* Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
|
|
26089
|
-
* according to the compiler used.
|
|
26090
26095
|
*/
|
|
26091
|
-
class
|
|
26096
|
+
class TestBedImpl {
|
|
26092
26097
|
constructor() {
|
|
26093
26098
|
// Properties
|
|
26094
26099
|
this.platform = null;
|
|
@@ -26096,7 +26101,15 @@ class TestBedRender3 {
|
|
|
26096
26101
|
this._compiler = null;
|
|
26097
26102
|
this._testModuleRef = null;
|
|
26098
26103
|
this._activeFixtures = [];
|
|
26099
|
-
|
|
26104
|
+
/**
|
|
26105
|
+
* Internal-only flag to indicate whether a module
|
|
26106
|
+
* scoping queue has been checked and flushed already.
|
|
26107
|
+
* @nodoc
|
|
26108
|
+
*/
|
|
26109
|
+
this.globalCompilationChecked = false;
|
|
26110
|
+
}
|
|
26111
|
+
static get INSTANCE() {
|
|
26112
|
+
return TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl();
|
|
26100
26113
|
}
|
|
26101
26114
|
/**
|
|
26102
26115
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
@@ -26112,7 +26125,7 @@ class TestBedRender3 {
|
|
|
26112
26125
|
* @publicApi
|
|
26113
26126
|
*/
|
|
26114
26127
|
static initTestEnvironment(ngModule, platform, options) {
|
|
26115
|
-
const testBed =
|
|
26128
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26116
26129
|
testBed.initTestEnvironment(ngModule, platform, options);
|
|
26117
26130
|
return testBed;
|
|
26118
26131
|
}
|
|
@@ -26122,19 +26135,17 @@ class TestBedRender3 {
|
|
|
26122
26135
|
* @publicApi
|
|
26123
26136
|
*/
|
|
26124
26137
|
static resetTestEnvironment() {
|
|
26125
|
-
|
|
26138
|
+
TestBedImpl.INSTANCE.resetTestEnvironment();
|
|
26126
26139
|
}
|
|
26127
26140
|
static configureCompiler(config) {
|
|
26128
|
-
|
|
26129
|
-
return TestBedRender3;
|
|
26141
|
+
return TestBedImpl.INSTANCE.configureCompiler(config);
|
|
26130
26142
|
}
|
|
26131
26143
|
/**
|
|
26132
26144
|
* Allows overriding default providers, directives, pipes, modules of the test injector,
|
|
26133
26145
|
* which are defined in test_injector.js
|
|
26134
26146
|
*/
|
|
26135
26147
|
static configureTestingModule(moduleDef) {
|
|
26136
|
-
|
|
26137
|
-
return TestBedRender3;
|
|
26148
|
+
return TestBedImpl.INSTANCE.configureTestingModule(moduleDef);
|
|
26138
26149
|
}
|
|
26139
26150
|
/**
|
|
26140
26151
|
* Compile components with a `templateUrl` for the test's NgModule.
|
|
@@ -26142,27 +26153,22 @@ class TestBedRender3 {
|
|
|
26142
26153
|
* as fetching urls is asynchronous.
|
|
26143
26154
|
*/
|
|
26144
26155
|
static compileComponents() {
|
|
26145
|
-
return
|
|
26156
|
+
return TestBedImpl.INSTANCE.compileComponents();
|
|
26146
26157
|
}
|
|
26147
26158
|
static overrideModule(ngModule, override) {
|
|
26148
|
-
|
|
26149
|
-
return TestBedRender3;
|
|
26159
|
+
return TestBedImpl.INSTANCE.overrideModule(ngModule, override);
|
|
26150
26160
|
}
|
|
26151
26161
|
static overrideComponent(component, override) {
|
|
26152
|
-
|
|
26153
|
-
return TestBedRender3;
|
|
26162
|
+
return TestBedImpl.INSTANCE.overrideComponent(component, override);
|
|
26154
26163
|
}
|
|
26155
26164
|
static overrideDirective(directive, override) {
|
|
26156
|
-
|
|
26157
|
-
return TestBedRender3;
|
|
26165
|
+
return TestBedImpl.INSTANCE.overrideDirective(directive, override);
|
|
26158
26166
|
}
|
|
26159
26167
|
static overridePipe(pipe, override) {
|
|
26160
|
-
|
|
26161
|
-
return TestBedRender3;
|
|
26168
|
+
return TestBedImpl.INSTANCE.overridePipe(pipe, override);
|
|
26162
26169
|
}
|
|
26163
26170
|
static overrideTemplate(component, template) {
|
|
26164
|
-
|
|
26165
|
-
return TestBedRender3;
|
|
26171
|
+
return TestBedImpl.INSTANCE.overrideTemplate(component, template);
|
|
26166
26172
|
}
|
|
26167
26173
|
/**
|
|
26168
26174
|
* Overrides the template of the given component, compiling the template
|
|
@@ -26171,32 +26177,32 @@ class TestBedRender3 {
|
|
|
26171
26177
|
* Note: This works for JIT and AOTed components as well.
|
|
26172
26178
|
*/
|
|
26173
26179
|
static overrideTemplateUsingTestingModule(component, template) {
|
|
26174
|
-
|
|
26175
|
-
return TestBedRender3;
|
|
26180
|
+
return TestBedImpl.INSTANCE.overrideTemplateUsingTestingModule(component, template);
|
|
26176
26181
|
}
|
|
26177
26182
|
static overrideProvider(token, provider) {
|
|
26178
|
-
|
|
26179
|
-
return TestBedRender3;
|
|
26183
|
+
return TestBedImpl.INSTANCE.overrideProvider(token, provider);
|
|
26180
26184
|
}
|
|
26181
26185
|
static inject(token, notFoundValue, flags) {
|
|
26182
|
-
return
|
|
26186
|
+
return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
|
|
26183
26187
|
}
|
|
26184
26188
|
/** @deprecated from v9.0.0 use TestBed.inject */
|
|
26185
26189
|
static get(token, notFoundValue = Injector$1.THROW_IF_NOT_FOUND, flags = InjectFlags$1.Default) {
|
|
26186
|
-
return
|
|
26190
|
+
return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
|
|
26187
26191
|
}
|
|
26188
26192
|
static createComponent(component) {
|
|
26189
|
-
return
|
|
26193
|
+
return TestBedImpl.INSTANCE.createComponent(component);
|
|
26190
26194
|
}
|
|
26191
26195
|
static resetTestingModule() {
|
|
26192
|
-
|
|
26193
|
-
|
|
26196
|
+
return TestBedImpl.INSTANCE.resetTestingModule();
|
|
26197
|
+
}
|
|
26198
|
+
static execute(tokens, fn, context) {
|
|
26199
|
+
return TestBedImpl.INSTANCE.execute(tokens, fn, context);
|
|
26194
26200
|
}
|
|
26195
|
-
static
|
|
26196
|
-
return
|
|
26201
|
+
static get platform() {
|
|
26202
|
+
return TestBedImpl.INSTANCE.platform;
|
|
26197
26203
|
}
|
|
26198
|
-
static
|
|
26199
|
-
|
|
26204
|
+
static get ngModule() {
|
|
26205
|
+
return TestBedImpl.INSTANCE.ngModule;
|
|
26200
26206
|
}
|
|
26201
26207
|
/**
|
|
26202
26208
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
@@ -26215,12 +26221,12 @@ class TestBedRender3 {
|
|
|
26215
26221
|
if (this.platform || this.ngModule) {
|
|
26216
26222
|
throw new Error('Cannot set base providers because it has already been called');
|
|
26217
26223
|
}
|
|
26218
|
-
|
|
26219
|
-
|
|
26220
|
-
|
|
26224
|
+
TestBedImpl._environmentTeardownOptions = options === null || options === void 0 ? void 0 : options.teardown;
|
|
26225
|
+
TestBedImpl._environmentErrorOnUnknownElementsOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownElements;
|
|
26226
|
+
TestBedImpl._environmentErrorOnUnknownPropertiesOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownProperties;
|
|
26221
26227
|
this.platform = platform;
|
|
26222
26228
|
this.ngModule = ngModule;
|
|
26223
|
-
this._compiler = new
|
|
26229
|
+
this._compiler = new TestBedCompiler(this.platform, this.ngModule);
|
|
26224
26230
|
// TestBed does not have an API which can reliably detect the start of a test, and thus could be
|
|
26225
26231
|
// used to track the state of the NgModule registry and reset it correctly. Instead, when we
|
|
26226
26232
|
// know we're in a testing scenario, we disable the check for duplicate NgModule registration
|
|
@@ -26237,7 +26243,7 @@ class TestBedRender3 {
|
|
|
26237
26243
|
this._compiler = null;
|
|
26238
26244
|
this.platform = null;
|
|
26239
26245
|
this.ngModule = null;
|
|
26240
|
-
|
|
26246
|
+
TestBedImpl._environmentTeardownOptions = undefined;
|
|
26241
26247
|
ɵsetAllowDuplicateNgModuleIdsForTest(false);
|
|
26242
26248
|
}
|
|
26243
26249
|
resetTestingModule() {
|
|
@@ -26247,7 +26253,7 @@ class TestBedRender3 {
|
|
|
26247
26253
|
if (this._compiler !== null) {
|
|
26248
26254
|
this.compiler.restoreOriginalState();
|
|
26249
26255
|
}
|
|
26250
|
-
this._compiler = new
|
|
26256
|
+
this._compiler = new TestBedCompiler(this.platform, this.ngModule);
|
|
26251
26257
|
// Restore the previous value of the "error on unknown elements" option
|
|
26252
26258
|
ɵsetUnknownElementStrictMode$1((_a = this._previousErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a : THROW_ON_UNKNOWN_ELEMENTS_DEFAULT);
|
|
26253
26259
|
// Restore the previous value of the "error on unknown properties" option
|
|
@@ -26271,6 +26277,7 @@ class TestBedRender3 {
|
|
|
26271
26277
|
this._instanceErrorOnUnknownPropertiesOption = undefined;
|
|
26272
26278
|
}
|
|
26273
26279
|
}
|
|
26280
|
+
return this;
|
|
26274
26281
|
}
|
|
26275
26282
|
configureCompiler(config) {
|
|
26276
26283
|
if (config.useJit != null) {
|
|
@@ -26279,6 +26286,7 @@ class TestBedRender3 {
|
|
|
26279
26286
|
if (config.providers !== undefined) {
|
|
26280
26287
|
this.compiler.setCompilerProviders(config.providers);
|
|
26281
26288
|
}
|
|
26289
|
+
return this;
|
|
26282
26290
|
}
|
|
26283
26291
|
configureTestingModule(moduleDef) {
|
|
26284
26292
|
this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
|
|
@@ -26299,12 +26307,13 @@ class TestBedRender3 {
|
|
|
26299
26307
|
this._previousErrorOnUnknownPropertiesOption = ɵgetUnknownPropertyStrictMode$1();
|
|
26300
26308
|
ɵsetUnknownPropertyStrictMode$1(this.shouldThrowErrorOnUnknownProperties());
|
|
26301
26309
|
this.compiler.configureTestingModule(moduleDef);
|
|
26310
|
+
return this;
|
|
26302
26311
|
}
|
|
26303
26312
|
compileComponents() {
|
|
26304
26313
|
return this.compiler.compileComponents();
|
|
26305
26314
|
}
|
|
26306
26315
|
inject(token, notFoundValue, flags) {
|
|
26307
|
-
if (token ===
|
|
26316
|
+
if (token === TestBed) {
|
|
26308
26317
|
return this;
|
|
26309
26318
|
}
|
|
26310
26319
|
const UNDEFINED = {};
|
|
@@ -26323,22 +26332,27 @@ class TestBedRender3 {
|
|
|
26323
26332
|
overrideModule(ngModule, override) {
|
|
26324
26333
|
this.assertNotInstantiated('overrideModule', 'override module metadata');
|
|
26325
26334
|
this.compiler.overrideModule(ngModule, override);
|
|
26335
|
+
return this;
|
|
26326
26336
|
}
|
|
26327
26337
|
overrideComponent(component, override) {
|
|
26328
26338
|
this.assertNotInstantiated('overrideComponent', 'override component metadata');
|
|
26329
26339
|
this.compiler.overrideComponent(component, override);
|
|
26340
|
+
return this;
|
|
26330
26341
|
}
|
|
26331
26342
|
overrideTemplateUsingTestingModule(component, template) {
|
|
26332
26343
|
this.assertNotInstantiated('R3TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
|
|
26333
26344
|
this.compiler.overrideTemplateUsingTestingModule(component, template);
|
|
26345
|
+
return this;
|
|
26334
26346
|
}
|
|
26335
26347
|
overrideDirective(directive, override) {
|
|
26336
26348
|
this.assertNotInstantiated('overrideDirective', 'override directive metadata');
|
|
26337
26349
|
this.compiler.overrideDirective(directive, override);
|
|
26350
|
+
return this;
|
|
26338
26351
|
}
|
|
26339
26352
|
overridePipe(pipe, override) {
|
|
26340
26353
|
this.assertNotInstantiated('overridePipe', 'override pipe metadata');
|
|
26341
26354
|
this.compiler.overridePipe(pipe, override);
|
|
26355
|
+
return this;
|
|
26342
26356
|
}
|
|
26343
26357
|
/**
|
|
26344
26358
|
* Overwrites all providers for the given token with the given provider definition.
|
|
@@ -26346,6 +26360,10 @@ class TestBedRender3 {
|
|
|
26346
26360
|
overrideProvider(token, provider) {
|
|
26347
26361
|
this.assertNotInstantiated('overrideProvider', 'override provider');
|
|
26348
26362
|
this.compiler.overrideProvider(token, provider);
|
|
26363
|
+
return this;
|
|
26364
|
+
}
|
|
26365
|
+
overrideTemplate(component, template) {
|
|
26366
|
+
return this.overrideComponent(component, { set: { template, templateUrl: null } });
|
|
26349
26367
|
}
|
|
26350
26368
|
createComponent(type) {
|
|
26351
26369
|
const testComponentRenderer = this.inject(TestComponentRenderer);
|
|
@@ -26410,10 +26428,10 @@ class TestBedRender3 {
|
|
|
26410
26428
|
checkGlobalCompilationFinished() {
|
|
26411
26429
|
// Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
|
|
26412
26430
|
// guard that compilations queued in tests (after instantiation) are never flushed accidentally.
|
|
26413
|
-
if (!this.
|
|
26431
|
+
if (!this.globalCompilationChecked && this._testModuleRef === null) {
|
|
26414
26432
|
ɵflushModuleScopingQueueAsMuchAsPossible();
|
|
26415
26433
|
}
|
|
26416
|
-
this.
|
|
26434
|
+
this.globalCompilationChecked = true;
|
|
26417
26435
|
}
|
|
26418
26436
|
destroyActiveFixtures() {
|
|
26419
26437
|
let errorCount = 0;
|
|
@@ -26438,7 +26456,7 @@ class TestBedRender3 {
|
|
|
26438
26456
|
shouldRethrowTeardownErrors() {
|
|
26439
26457
|
var _a, _b;
|
|
26440
26458
|
const instanceOptions = this._instanceTeardownOptions;
|
|
26441
|
-
const environmentOptions =
|
|
26459
|
+
const environmentOptions = TestBedImpl._environmentTeardownOptions;
|
|
26442
26460
|
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
26443
26461
|
if (!instanceOptions && !environmentOptions) {
|
|
26444
26462
|
return TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
@@ -26449,16 +26467,16 @@ class TestBedRender3 {
|
|
|
26449
26467
|
shouldThrowErrorOnUnknownElements() {
|
|
26450
26468
|
var _a, _b;
|
|
26451
26469
|
// Check if a configuration has been provided to throw when an unknown element is found
|
|
26452
|
-
return (_b = (_a = this._instanceErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a :
|
|
26470
|
+
return (_b = (_a = this._instanceErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a : TestBedImpl._environmentErrorOnUnknownElementsOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
|
|
26453
26471
|
}
|
|
26454
26472
|
shouldThrowErrorOnUnknownProperties() {
|
|
26455
26473
|
var _a, _b;
|
|
26456
26474
|
// Check if a configuration has been provided to throw when an unknown property is found
|
|
26457
|
-
return (_b = (_a = this._instanceErrorOnUnknownPropertiesOption) !== null && _a !== void 0 ? _a :
|
|
26475
|
+
return (_b = (_a = this._instanceErrorOnUnknownPropertiesOption) !== null && _a !== void 0 ? _a : TestBedImpl._environmentErrorOnUnknownPropertiesOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_PROPERTIES_DEFAULT;
|
|
26458
26476
|
}
|
|
26459
26477
|
shouldTearDownTestingModule() {
|
|
26460
26478
|
var _a, _b, _c, _d;
|
|
26461
|
-
return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c =
|
|
26479
|
+
return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedImpl._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
26462
26480
|
}
|
|
26463
26481
|
tearDownTestingModule() {
|
|
26464
26482
|
var _a;
|
|
@@ -26488,18 +26506,7 @@ class TestBedRender3 {
|
|
|
26488
26506
|
}
|
|
26489
26507
|
}
|
|
26490
26508
|
}
|
|
26491
|
-
|
|
26492
|
-
function _getTestBedRender3() {
|
|
26493
|
-
return testBed = testBed || new TestBedRender3();
|
|
26494
|
-
}
|
|
26495
|
-
|
|
26496
|
-
/**
|
|
26497
|
-
* @license
|
|
26498
|
-
* Copyright Google LLC All Rights Reserved.
|
|
26499
|
-
*
|
|
26500
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
26501
|
-
* found in the LICENSE file at https://angular.io/license
|
|
26502
|
-
*/
|
|
26509
|
+
TestBedImpl._INSTANCE = null;
|
|
26503
26510
|
/**
|
|
26504
26511
|
* @description
|
|
26505
26512
|
* Configures and initializes environment for unit testing and provides methods for
|
|
@@ -26507,20 +26514,9 @@ function _getTestBedRender3() {
|
|
|
26507
26514
|
*
|
|
26508
26515
|
* `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
|
|
26509
26516
|
*
|
|
26510
|
-
* Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
|
|
26511
|
-
* according to the compiler used.
|
|
26512
|
-
*
|
|
26513
|
-
* @publicApi
|
|
26514
|
-
*/
|
|
26515
|
-
const TestBed = TestBedRender3;
|
|
26516
|
-
/**
|
|
26517
|
-
* Returns a singleton of the applicable `TestBed`.
|
|
26518
|
-
*
|
|
26519
|
-
* It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
|
|
26520
|
-
*
|
|
26521
26517
|
* @publicApi
|
|
26522
26518
|
*/
|
|
26523
|
-
const
|
|
26519
|
+
const TestBed = TestBedImpl;
|
|
26524
26520
|
/**
|
|
26525
26521
|
* Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
|
|
26526
26522
|
* (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
|
|
@@ -26544,7 +26540,7 @@ const getTestBed = _getTestBedRender3;
|
|
|
26544
26540
|
* @publicApi
|
|
26545
26541
|
*/
|
|
26546
26542
|
function inject(tokens, fn) {
|
|
26547
|
-
const testBed =
|
|
26543
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26548
26544
|
// Not using an arrow function to preserve context passed from call site
|
|
26549
26545
|
return function () {
|
|
26550
26546
|
return testBed.execute(tokens, fn, this);
|
|
@@ -26560,7 +26556,7 @@ class InjectSetupWrapper {
|
|
|
26560
26556
|
_addModule() {
|
|
26561
26557
|
const moduleDef = this._moduleDef();
|
|
26562
26558
|
if (moduleDef) {
|
|
26563
|
-
|
|
26559
|
+
TestBedImpl.configureTestingModule(moduleDef);
|
|
26564
26560
|
}
|
|
26565
26561
|
}
|
|
26566
26562
|
inject(tokens, fn) {
|
|
@@ -26576,7 +26572,7 @@ function withModule(moduleDef, fn) {
|
|
|
26576
26572
|
if (fn) {
|
|
26577
26573
|
// Not using an arrow function to preserve context passed from call site
|
|
26578
26574
|
return function () {
|
|
26579
|
-
const testBed =
|
|
26575
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26580
26576
|
if (moduleDef) {
|
|
26581
26577
|
testBed.configureTestingModule(moduleDef);
|
|
26582
26578
|
}
|
|
@@ -26606,9 +26602,9 @@ if (_global.afterEach) {
|
|
|
26606
26602
|
}
|
|
26607
26603
|
function getCleanupHook(expectedTeardownValue) {
|
|
26608
26604
|
return () => {
|
|
26609
|
-
|
|
26610
|
-
if (
|
|
26611
|
-
|
|
26605
|
+
const testBed = TestBedImpl.INSTANCE;
|
|
26606
|
+
if (testBed.shouldTearDownTestingModule() === expectedTeardownValue) {
|
|
26607
|
+
testBed.resetTestingModule();
|
|
26612
26608
|
resetFakeAsyncZone();
|
|
26613
26609
|
}
|
|
26614
26610
|
};
|