@angular/core 12.0.0-rc.3 → 12.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 +46 -83
- package/bundles/core-testing.umd.js.map +1 -1
- package/bundles/core.umd.js +29 -21
- package/bundles/core.umd.js.map +1 -1
- package/core.d.ts +194 -15
- package/core.metadata.json +1 -1
- package/esm2015/src/change_detection/differs/iterable_differs.js +1 -1
- package/esm2015/src/debug/debug_node.js +1 -1
- package/esm2015/src/di/injectable.js +1 -1
- package/esm2015/src/metadata/di.js +1 -1
- package/esm2015/src/metadata/do_boostrap.js +1 -1
- package/esm2015/src/render3/instructions/listener.js +6 -3
- package/esm2015/src/render3/util/discovery_utils.js +18 -12
- package/esm2015/src/render3/view_ref.js +3 -3
- package/esm2015/src/version.js +5 -6
- package/esm2015/testing/src/fake_async.js +42 -25
- package/esm2015/testing/src/test_bed.js +5 -25
- package/esm2015/testing/src/testing_internal.js +1 -182
- package/fesm2015/core.js +29 -21
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +46 -76
- package/fesm2015/testing.js.map +1 -1
- package/package.json +2 -5
- package/schematics/migrations/deep-shadow-piercing-selector/index.d.ts +10 -0
- package/schematics/migrations/deep-shadow-piercing-selector/index.js +49 -0
- package/schematics/migrations.json +5 -0
- package/src/r3_symbols.d.ts +1 -1
- package/testing/testing.d.ts +42 -30
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
- package/esm2015/testing/src/async_test_completer.js +0 -28
package/fesm2015/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.0.
|
|
2
|
+
* @license Angular v12.0.3
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -273,21 +273,25 @@ function resetFakeAsyncZone() {
|
|
|
273
273
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
|
-
* Wraps a function to be executed in the fakeAsync zone:
|
|
277
|
-
* -
|
|
278
|
-
* -
|
|
276
|
+
* Wraps a function to be executed in the `fakeAsync` zone:
|
|
277
|
+
* - Microtasks are manually executed by calling `flushMicrotasks()`.
|
|
278
|
+
* - Timers are synchronous; `tick()` simulates the asynchronous passage of time.
|
|
279
279
|
*
|
|
280
|
-
* If there are any pending timers at the end of the function, an exception
|
|
280
|
+
* If there are any pending timers at the end of the function, an exception is thrown.
|
|
281
281
|
*
|
|
282
|
-
* Can be used to wrap inject() calls.
|
|
282
|
+
* Can be used to wrap `inject()` calls.
|
|
283
|
+
*
|
|
284
|
+
* @param fn The function that you want to wrap in the `fakeAysnc` zone.
|
|
283
285
|
*
|
|
284
286
|
* @usageNotes
|
|
285
287
|
* ### Example
|
|
286
288
|
*
|
|
287
289
|
* {@example core/testing/ts/fake_async.ts region='basic'}
|
|
288
290
|
*
|
|
289
|
-
*
|
|
290
|
-
* @returns The function wrapped to be executed in the fakeAsync zone
|
|
291
|
+
*
|
|
292
|
+
* @returns The function wrapped to be executed in the `fakeAsync` zone.
|
|
293
|
+
* Any arguments passed when calling this returned function will be passed through to the `fn`
|
|
294
|
+
* function in the parameters when it is called.
|
|
291
295
|
*
|
|
292
296
|
* @publicApi
|
|
293
297
|
*/
|
|
@@ -298,23 +302,36 @@ function fakeAsync(fn) {
|
|
|
298
302
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
299
303
|
}
|
|
300
304
|
/**
|
|
301
|
-
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
|
|
305
|
+
* Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
|
|
302
306
|
*
|
|
303
307
|
* The microtasks queue is drained at the very start of this function and after any timer callback
|
|
304
308
|
* has been executed.
|
|
305
309
|
*
|
|
310
|
+
* @param millis The number of milliseconds to advance the virtual timer.
|
|
311
|
+
* @param tickOptions The options to pass to the `tick()` function.
|
|
312
|
+
*
|
|
306
313
|
* @usageNotes
|
|
314
|
+
*
|
|
315
|
+
* The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
|
|
316
|
+
* which determines whether or not to invoke new macroTasks.
|
|
317
|
+
*
|
|
318
|
+
* If you provide a `tickOptions` object, but do not specify a
|
|
319
|
+
* `processNewMacroTasksSynchronously` property (`tick(100, {})`),
|
|
320
|
+
* then `processNewMacroTasksSynchronously` defaults to true.
|
|
321
|
+
*
|
|
322
|
+
* If you omit the `tickOptions` parameter (`tick(100))`), then
|
|
323
|
+
* `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
|
|
324
|
+
*
|
|
307
325
|
* ### Example
|
|
308
326
|
*
|
|
309
327
|
* {@example core/testing/ts/fake_async.ts region='basic'}
|
|
310
328
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* processNewMacroTasksSynchronously
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* For example,
|
|
329
|
+
* The following example includes a nested timeout (new macroTask), and
|
|
330
|
+
* the `tickOptions` parameter is allowed to default. In this case,
|
|
331
|
+
* `processNewMacroTasksSynchronously` defaults to true, and the nested
|
|
332
|
+
* function is executed on each tick.
|
|
317
333
|
*
|
|
334
|
+
* ```
|
|
318
335
|
* it ('test with nested setTimeout', fakeAsync(() => {
|
|
319
336
|
* let nestedTimeoutInvoked = false;
|
|
320
337
|
* function funcWithNestedTimeout() {
|
|
@@ -326,10 +343,12 @@ function fakeAsync(fn) {
|
|
|
326
343
|
* tick();
|
|
327
344
|
* expect(nestedTimeoutInvoked).toBe(true);
|
|
328
345
|
* }));
|
|
346
|
+
* ```
|
|
329
347
|
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
348
|
+
* In the following case, `processNewMacroTasksSynchronously` is explicitly
|
|
349
|
+
* set to false, so the nested timeout function is not invoked.
|
|
332
350
|
*
|
|
351
|
+
* ```
|
|
333
352
|
* it ('test with nested setTimeout', fakeAsync(() => {
|
|
334
353
|
* let nestedTimeoutInvoked = false;
|
|
335
354
|
* function funcWithNestedTimeout() {
|
|
@@ -341,9 +360,7 @@ function fakeAsync(fn) {
|
|
|
341
360
|
* tick(0, {processNewMacroTasksSynchronously: false});
|
|
342
361
|
* expect(nestedTimeoutInvoked).toBe(false);
|
|
343
362
|
* }));
|
|
344
|
-
*
|
|
345
|
-
* if we pass the tickOptions with processNewMacroTasksSynchronously to be false, the nested timeout
|
|
346
|
-
* will not be invoked.
|
|
363
|
+
* ```
|
|
347
364
|
*
|
|
348
365
|
*
|
|
349
366
|
* @publicApi
|
|
@@ -357,12 +374,12 @@ function tick(millis = 0, tickOptions = {
|
|
|
357
374
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
358
375
|
}
|
|
359
376
|
/**
|
|
360
|
-
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
|
|
361
|
-
* draining the macrotask queue until it is empty.
|
|
362
|
-
* of time that would have been elapsed.
|
|
377
|
+
* Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone by
|
|
378
|
+
* draining the macrotask queue until it is empty.
|
|
363
379
|
*
|
|
364
|
-
* @param maxTurns
|
|
365
|
-
*
|
|
380
|
+
* @param maxTurns The maximum number of times the scheduler attempts to clear its queue before
|
|
381
|
+
* throwing an error.
|
|
382
|
+
* @returns The simulated time elapsed, in milliseconds.
|
|
366
383
|
*
|
|
367
384
|
* @publicApi
|
|
368
385
|
*/
|
|
@@ -395,34 +412,6 @@ function flushMicrotasks() {
|
|
|
395
412
|
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
|
|
396
413
|
}
|
|
397
414
|
|
|
398
|
-
/**
|
|
399
|
-
* @license
|
|
400
|
-
* Copyright Google LLC All Rights Reserved.
|
|
401
|
-
*
|
|
402
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
403
|
-
* found in the LICENSE file at https://angular.io/license
|
|
404
|
-
*/
|
|
405
|
-
/**
|
|
406
|
-
* Injectable completer that allows signaling completion of an asynchronous test. Used internally.
|
|
407
|
-
*/
|
|
408
|
-
class AsyncTestCompleter {
|
|
409
|
-
constructor() {
|
|
410
|
-
this._promise = new Promise((res, rej) => {
|
|
411
|
-
this._resolve = res;
|
|
412
|
-
this._reject = rej;
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
done(value) {
|
|
416
|
-
this._resolve(value);
|
|
417
|
-
}
|
|
418
|
-
fail(error, stackTrace) {
|
|
419
|
-
this._reject(error);
|
|
420
|
-
}
|
|
421
|
-
get promise() {
|
|
422
|
-
return this._promise;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
415
|
/**
|
|
427
416
|
* @license
|
|
428
417
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2342,33 +2331,14 @@ function _getTestBedViewEngine() {
|
|
|
2342
2331
|
* })
|
|
2343
2332
|
* ```
|
|
2344
2333
|
*
|
|
2345
|
-
* Notes:
|
|
2346
|
-
* - inject is currently a function because of some Traceur limitation the syntax should
|
|
2347
|
-
* eventually
|
|
2348
|
-
* becomes `it('...', @Inject (object: AClass, async: AsyncTestCompleter) => { ... });`
|
|
2349
|
-
*
|
|
2350
2334
|
* @publicApi
|
|
2351
2335
|
*/
|
|
2352
2336
|
function inject(tokens, fn) {
|
|
2353
2337
|
const testBed = getTestBed();
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
return
|
|
2357
|
-
|
|
2358
|
-
// the injected tokens.
|
|
2359
|
-
return testBed.compileComponents().then(() => {
|
|
2360
|
-
const completer = testBed.inject(AsyncTestCompleter);
|
|
2361
|
-
testBed.execute(tokens, fn, this);
|
|
2362
|
-
return completer.promise;
|
|
2363
|
-
});
|
|
2364
|
-
};
|
|
2365
|
-
}
|
|
2366
|
-
else {
|
|
2367
|
-
// Not using an arrow function to preserve context passed from call site
|
|
2368
|
-
return function () {
|
|
2369
|
-
return testBed.execute(tokens, fn, this);
|
|
2370
|
-
};
|
|
2371
|
-
}
|
|
2338
|
+
// Not using an arrow function to preserve context passed from call site
|
|
2339
|
+
return function () {
|
|
2340
|
+
return testBed.execute(tokens, fn, this);
|
|
2341
|
+
};
|
|
2372
2342
|
}
|
|
2373
2343
|
/**
|
|
2374
2344
|
* @publicApi
|