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.
This commit is contained in:
SkyZeroZx
2026-09-08 21:20:01 -05:00
committed by Andrew Scott
parent fc2f6fd67d
commit c60c41e29a
5 changed files with 317 additions and 345 deletions
@@ -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);