|
| 1 | +/** |
| 2 | + * Copyright (c) 2013-present, Facebook, Inc. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @emails react-core |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +// TODO: delete or change this test. |
| 13 | +describe('ReactDOMFrameScheduling', () => { |
| 14 | + it('warns when requestAnimationFrame is not polyfilled in the browser', () => { |
| 15 | + const previousRAF = global.requestAnimationFrame; |
| 16 | + try { |
| 17 | + global.requestAnimationFrame = undefined; |
| 18 | + jest.resetModules(); |
| 19 | + expect(() => require('react-dom')).toWarnDev( |
| 20 | + 'React depends on requestAnimationFrame.', |
| 21 | + ); |
| 22 | + } finally { |
| 23 | + global.requestAnimationFrame = previousRAF; |
| 24 | + } |
| 25 | + }); |
| 26 | + |
| 27 | + // We're just testing importing, not using it. |
| 28 | + // It is important because even isomorphic components may import it. |
| 29 | + it('can import findDOMNode in Node environment', () => { |
| 30 | + const previousRAF = global.requestAnimationFrame; |
| 31 | + const previousRIC = global.requestIdleCallback; |
| 32 | + const prevWindow = global.window; |
| 33 | + try { |
| 34 | + global.requestAnimationFrame = undefined; |
| 35 | + global.requestIdleCallback = undefined; |
| 36 | + // Simulate the Node environment: |
| 37 | + delete global.window; |
| 38 | + jest.resetModules(); |
| 39 | + expect(() => { |
| 40 | + require('react-dom'); |
| 41 | + }).not.toThrow(); |
| 42 | + } finally { |
| 43 | + global.requestAnimationFrame = previousRAF; |
| 44 | + global.requestIdleCallback = previousRIC; |
| 45 | + global.window = prevWindow; |
| 46 | + } |
| 47 | + }); |
| 48 | +}); |
0 commit comments