Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 62b8525

Browse files
JiaLiPassionvikerman
authored andcommitted
fix: fakeAsyncTest requestAnimationFrame should pass timestamp as parameter (#1220)
Close #1216
1 parent 32f3a93 commit 62b8525

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: lib/zone-spec/fake-async-test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class Scheduler {
143143
if (doTick) {
144144
doTick(this._currentTime - lastCurrentTime);
145145
}
146-
let retval = current.func.apply(global, current.args);
146+
let retval = current.func.apply(
147+
global, current.isRequestAnimationFrame ? [this._currentTime] : current.args);
147148
if (!retval) {
148149
// Uncaught exception in the current scheduled function. Stop processing the queue.
149150
break;

Diff for: test/zone-spec/fake-async-test.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,24 @@ describe('FakeAsyncTestZoneSpec', () => {
741741
expect(ran).toEqual(true);
742742
});
743743
});
744+
it('should pass timestamp as parameter', () => {
745+
let timestamp = 0;
746+
let timestamp1 = 0;
747+
fakeAsyncTestZone.run(() => {
748+
requestAnimationFrame((ts) => {
749+
timestamp = ts;
750+
requestAnimationFrame(ts1 => {
751+
timestamp1 = ts1;
752+
});
753+
});
754+
const elapsed = testZoneSpec.flush(20, true);
755+
const elapsed1 = testZoneSpec.flush(20, true);
756+
expect(elapsed).toEqual(16);
757+
expect(elapsed1).toEqual(16);
758+
expect(timestamp).toEqual(16);
759+
expect(timestamp1).toEqual(32);
760+
});
761+
});
744762
}));
745763
});
746764
});

0 commit comments

Comments
 (0)