Skip to content

Commit

Permalink
adding another test to be super safe. Also improving some testing lan…
Browse files Browse the repository at this point in the history
…guage
  • Loading branch information
alexreardon committed Oct 4, 2023
1 parent d1ae881 commit 2c69f29
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions packages/jest-fake-timers/src/__tests__/modernFakeTimers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ describe('FakeTimers', () => {
});

describe('advanceTimersToNextFrame', () => {
it('runs scheduled animation frames in order', () => {
it('runs scheduled animation frame callbacks in order', () => {
const global = {
Date,
clearTimeout,
Expand All @@ -621,7 +621,7 @@ describe('FakeTimers', () => {
expect(runOrder).toEqual(['mock1', 'mock2', 'mock3']);
});

it('should only run currently scheduled animation frames', () => {
it('should only run currently scheduled animation frame callbacks', () => {
const global = {
Date,
clearTimeout,
Expand Down Expand Up @@ -653,7 +653,7 @@ describe('FakeTimers', () => {
expect(runOrder).toEqual(['first-frame', 'second-frame']);
});

it('should allow cancelling of scheduled animation frames', () => {
it('should allow cancelling of scheduled animation frame callbacks', () => {
const global = {
Date,
cancelAnimationFrame: () => {},
Expand Down Expand Up @@ -738,7 +738,7 @@ describe('FakeTimers', () => {
expect(runOrder).toEqual(['timeout', 'frame']);
});

it('should not execute any timers scheduled inside of a frame', () => {
it('should not execute any timers scheduled inside of an animation frame callback', () => {
const global = {
Date,
cancelAnimationFrame: () => {},
Expand Down Expand Up @@ -791,6 +791,28 @@ describe('FakeTimers', () => {
// `requestAnimationFrame` callbacks are called with a `DOMHighResTimeStamp`
expect(callback).toHaveBeenCalledWith(global.performance.now());
});

it('should allow cancelling of scheduled animation frame callbacks', () => {

Check failure on line 795 in packages/jest-fake-timers/src/__tests__/modernFakeTimers.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Test title is used multiple times in the same describe block
const global = {
Date,
cancelAnimationFrame: () => {},
clearTimeout,
process,
requestAnimationFrame: () => -1,
setTimeout,
} as unknown as typeof globalThis;

const timers = new FakeTimers({config: makeProjectConfig(), global});
const callback = jest.fn();
timers.useFakeTimers();

const timerId = global.requestAnimationFrame(callback);
global.cancelAnimationFrame(timerId);

timers.advanceTimersToNextFrame();

expect(callback).not.toHaveBeenCalled();
});
});

describe('reset', () => {
Expand Down

0 comments on commit 2c69f29

Please sign in to comment.