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

Commit

Permalink
fix: fakeAsyncTest requestAnimationFrame should pass timestamp as par…
Browse files Browse the repository at this point in the history
…ameter (#1220)

Close #1216
  • Loading branch information
JiaLiPassion authored and vikerman committed Apr 9, 2019
1 parent 32f3a93 commit 62b8525
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 62b8525

Please sign in to comment.