mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
28 lines
639 B
JavaScript
28 lines
639 B
JavaScript
import { mount } from '@vue/test-utils'
|
|
import BackTop from '..'
|
|
|
|
describe('BackTop', () => {
|
|
beforeAll(() => {
|
|
jest.useFakeTimers()
|
|
})
|
|
|
|
afterAll(() => {
|
|
jest.useRealTimers()
|
|
})
|
|
|
|
it('should scroll to top after click it', () => {
|
|
const wrapper = mount(BackTop, {
|
|
propsData: {
|
|
visibilityHeight: -1,
|
|
},
|
|
})
|
|
document.documentElement.scrollTop = 400
|
|
// trigger scroll manually
|
|
wrapper.vm.handleScroll()
|
|
jest.runAllTimers()
|
|
wrapper.find('.ant-back-top').trigger('click')
|
|
jest.runAllTimers()
|
|
expect(Math.abs(Math.round(document.documentElement.scrollTop))).toBe(0)
|
|
})
|
|
})
|