diff --git a/e2e/fake-time/legacy/requestAnimationFrame/__tests__/test.js b/e2e/fake-time/legacy/requestAnimationFrame/__tests__/test.js new file mode 100644 index 000000000000..53fc89c6aa48 --- /dev/null +++ b/e2e/fake-time/legacy/requestAnimationFrame/__tests__/test.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +test('requestAnimationFrame', () => { + jest.useFakeTimers('legacy'); + let exited = false; + requestAnimationFrame(() => { + exited = true; + }); + + jest.advanceTimersByTime(15); + + expect(exited).toBe(false); + + jest.advanceTimersByTime(1); + + expect(exited).toBe(true); +}); diff --git a/e2e/fake-time/legacy/requestAnimationFrame/package.json b/e2e/fake-time/legacy/requestAnimationFrame/package.json new file mode 100644 index 000000000000..0ded940b7cb7 --- /dev/null +++ b/e2e/fake-time/legacy/requestAnimationFrame/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "testEnvironment": "jsdom" + } +} diff --git a/e2e/fake-time/modern/requestAnimationFrame/__tests__/test.js b/e2e/fake-time/modern/requestAnimationFrame/__tests__/test.js new file mode 100644 index 000000000000..53fc89c6aa48 --- /dev/null +++ b/e2e/fake-time/modern/requestAnimationFrame/__tests__/test.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +test('requestAnimationFrame', () => { + jest.useFakeTimers('legacy'); + let exited = false; + requestAnimationFrame(() => { + exited = true; + }); + + jest.advanceTimersByTime(15); + + expect(exited).toBe(false); + + jest.advanceTimersByTime(1); + + expect(exited).toBe(true); +}); diff --git a/e2e/fake-time/modern/requestAnimationFrame/package.json b/e2e/fake-time/modern/requestAnimationFrame/package.json new file mode 100644 index 000000000000..0ded940b7cb7 --- /dev/null +++ b/e2e/fake-time/modern/requestAnimationFrame/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "testEnvironment": "jsdom" + } +}