Run jest.useFakeTimers in beforeAll

This commit is contained in:
Wei Zhu 2017-11-13 10:46:22 +08:00
parent 16133aac65
commit 645be586f3
3 changed files with 14 additions and 6 deletions

View File

@ -1,11 +1,14 @@
import throttleByAnimationFrame from '../throttleByAnimationFrame';
jest.useFakeTimers();
describe('Test utils function', () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterAll(() => {
jest.useRealTimers();
});
it('throttle function should work', () => {
const callback = jest.fn();
const throttled = throttleByAnimationFrame(callback);

View File

@ -3,8 +3,6 @@ import { mount } from 'enzyme';
import Affix from '..';
import Button from '../../button';
jest.useFakeTimers();
const events = {};
class AffixMounter extends React.Component {
@ -48,9 +46,14 @@ class AffixMounter extends React.Component {
}
describe('Affix Render', () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterAll(() => {
jest.useRealTimers();
});
it('Anchor render perfectly', () => {
document.body.innerHTML = '<div id="mounter" />';

View File

@ -1,8 +1,10 @@
import notification from '..';
jest.useFakeTimers();
describe('notification', () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterAll(() => {
jest.useRealTimers();
});