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

fix: fakeAsyncTest requestAnimationFrame should pass timestamp as parameter #1220

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/zone-spec/fake-async-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class Scheduler {
if (doTick) {
doTick(this._currentTime - lastCurrentTime);
}
let retval = current.func.apply(global, current.args);
let retval = current.func.apply(
global, current.isRequestAnimationFrame ? [this._currentTime] : current.args);
if (!retval) {
// Uncaught exception in the current scheduled function. Stop processing the queue.
break;
Expand Down
18 changes: 18 additions & 0 deletions test/zone-spec/fake-async-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,24 @@ describe('FakeAsyncTestZoneSpec', () => {
expect(ran).toEqual(true);
});
});
it('should pass timestamp as parameter', () => {
let timestamp = 0;
let timestamp1 = 0;
fakeAsyncTestZone.run(() => {
requestAnimationFrame((ts) => {
timestamp = ts;
requestAnimationFrame(ts1 => {
timestamp1 = ts1;
});
});
const elapsed = testZoneSpec.flush(20, true);
const elapsed1 = testZoneSpec.flush(20, true);
expect(elapsed).toEqual(16);
expect(elapsed1).toEqual(16);
expect(timestamp).toEqual(16);
expect(timestamp1).toEqual(32);
});
});
}));
});
});
Expand Down