mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
test(core): reduce fakeAsync usage in animation tests
Use async/await in animation acceptance tests and share the animation frame helper. Remove the obsolete fakeAsync frame utility and its Bazel dependency.
(cherry picked from commit c60c41e29a)
This commit is contained in:
@@ -27,7 +27,6 @@ ts_project(
|
||||
"//packages/core/primitives/signals",
|
||||
"//packages/core/src/di/interface",
|
||||
"//packages/core/src/util",
|
||||
"//packages/core/test/animation_utils",
|
||||
"//packages/core/test/render3:matchers",
|
||||
"//packages/core/testing",
|
||||
"//packages/localize",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
load("//tools:defaults.bzl", "ts_project")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
ts_project(
|
||||
name = "animation_utils",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"tick_animation_frames.ts",
|
||||
],
|
||||
deps = [
|
||||
"//packages/core/testing",
|
||||
],
|
||||
)
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {tick} from '@angular/core/testing';
|
||||
|
||||
/** Ticks the specified amount of `requestAnimationFrame`-s. */
|
||||
export function tickAnimationFrames(amount: number) {
|
||||
tick(16.6 * amount); // Angular turns rAF calls into 16.6ms timeouts in tests.
|
||||
}
|
||||
@@ -9,6 +9,11 @@
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {NgZone} from '@angular/core';
|
||||
|
||||
/** Waits for callbacks queued for the next animation frame to run. */
|
||||
export function nextAnimationFrame(): Promise<void> {
|
||||
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
||||
}
|
||||
|
||||
export function dispatchEvent(element: any, eventType: any): Event {
|
||||
const evt: Event = getDOM().getDefaultDocument().createEvent('Event');
|
||||
evt.initEvent(eventType, true, true);
|
||||
|
||||
Reference in New Issue
Block a user