mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-02 20:18:22 +08:00
test: add back-top test
This commit is contained in:
parent
931495768f
commit
f8caf137b6
27
components/back-top/__tests__/index.test.js
Normal file
27
components/back-top/__tests__/index.test.js
Normal file
@ -0,0 +1,27 @@
|
||||
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)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user