ant-design/components/back-top/__tests__/index.test.js
偏右 ffffd0f4c5 Fix styles (#7924)
* update demo

* Fix styles

* fix snap

* Fix back-top ci
2017-10-18 17:16:14 +08:00

19 lines
554 B
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import BackTop from '..';
jest.useFakeTimers();
describe('BackTop', () => {
it('should scroll to top after click it', async () => {
const wrapper = mount(<BackTop visibilityHeight={-1} />);
document.documentElement.scrollTop = 400;
// trigger scroll manually
wrapper.instance().handleScroll();
jest.runAllTimers();
wrapper.find('.ant-back-top').simulate('click');
jest.runAllTimers();
expect(Math.round(document.documentElement.scrollTop)).toBe(0);
});
});