2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import BackTop from '..';
|
2018-05-19 09:20:30 +00:00
|
|
|
|
|
|
|
describe('BackTop', () => {
|
2019-01-02 12:56:06 +00:00
|
|
|
it('should scroll to top after click it', async () => {
|
2018-05-19 09:20:30 +00:00
|
|
|
const wrapper = mount(BackTop, {
|
|
|
|
propsData: {
|
|
|
|
visibilityHeight: -1,
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
document.documentElement.scrollTop = 400;
|
2018-05-19 09:20:30 +00:00
|
|
|
// trigger scroll manually
|
2019-01-12 03:33:27 +00:00
|
|
|
wrapper.vm.handleScroll();
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
|
|
wrapper.find('.ant-back-top').trigger('click');
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
|
|
expect(Math.abs(Math.round(document.documentElement.scrollTop))).toBe(0);
|
|
|
|
});
|
|
|
|
});
|