feat: update
parent
daccfd19d1
commit
9eb923c0f8
|
@ -117,7 +117,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
resetEffect (node) {
|
resetEffect (node) {
|
||||||
if (!node || node === this.extraNode) {
|
if (!node || node === this.extraNode || !(node instanceof Element)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const { insertExtraNode } = this.$props
|
const { insertExtraNode } = this.$props
|
||||||
|
|
|
@ -83,6 +83,8 @@ const Affix = {
|
||||||
// Wait for parent component ref has its value
|
// Wait for parent component ref has its value
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
this.setTargetEventListeners(target)
|
this.setTargetEventListeners(target)
|
||||||
|
// Mock Event object.
|
||||||
|
this.updatePosition({})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -2,15 +2,7 @@ import { mount } from '@vue/test-utils'
|
||||||
import BackTop from '..'
|
import BackTop from '..'
|
||||||
|
|
||||||
describe('BackTop', () => {
|
describe('BackTop', () => {
|
||||||
beforeAll(() => {
|
it('should scroll to top after click it', async () => {
|
||||||
jest.useFakeTimers()
|
|
||||||
})
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
jest.useRealTimers()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should scroll to top after click it', () => {
|
|
||||||
const wrapper = mount(BackTop, {
|
const wrapper = mount(BackTop, {
|
||||||
propsData: {
|
propsData: {
|
||||||
visibilityHeight: -1,
|
visibilityHeight: -1,
|
||||||
|
@ -19,9 +11,9 @@ describe('BackTop', () => {
|
||||||
document.documentElement.scrollTop = 400
|
document.documentElement.scrollTop = 400
|
||||||
// trigger scroll manually
|
// trigger scroll manually
|
||||||
wrapper.vm.handleScroll()
|
wrapper.vm.handleScroll()
|
||||||
jest.runAllTimers()
|
await new Promise(resolve => setTimeout(resolve, 0))
|
||||||
wrapper.find('.ant-back-top').trigger('click')
|
wrapper.find('.ant-back-top').trigger('click')
|
||||||
jest.runAllTimers()
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
expect(Math.abs(Math.round(document.documentElement.scrollTop))).toBe(0)
|
expect(Math.abs(Math.round(document.documentElement.scrollTop))).toBe(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -77,7 +77,7 @@ describe('Carousel', () => {
|
||||||
sync: true,
|
sync: true,
|
||||||
}
|
}
|
||||||
const wrapper = mount(Carousel, props)
|
const wrapper = mount(Carousel, props)
|
||||||
const onWindowResized = wrapper.vm.onWindowResized
|
const { onWindowResized } = wrapper.vm
|
||||||
const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel')
|
const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel')
|
||||||
const spy2 = jest.spyOn(window, 'removeEventListener')
|
const spy2 = jest.spyOn(window, 'removeEventListener')
|
||||||
wrapper.destroy()
|
wrapper.destroy()
|
||||||
|
|
Loading…
Reference in New Issue