mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 23:00:20 +08:00
25 lines
640 B
JavaScript
25 lines
640 B
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import BackTop from '..';
|
|
|
|
describe('BackTop', () => {
|
|
beforeAll(() => {
|
|
jest.useFakeTimers();
|
|
});
|
|
|
|
afterAll(() => {
|
|
jest.useRealTimers();
|
|
});
|
|
|
|
it('should scroll to top after click it', () => {
|
|
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.abs(Math.round(document.documentElement.scrollTop))).toBe(0);
|
|
});
|
|
});
|