feat: update

pull/398/head
tangjinzhou 2019-01-02 20:56:06 +08:00
parent daccfd19d1
commit 9eb923c0f8
4 changed files with 7 additions and 13 deletions

View File

@ -117,7 +117,7 @@ export default {
},
resetEffect (node) {
if (!node || node === this.extraNode) {
if (!node || node === this.extraNode || !(node instanceof Element)) {
return
}
const { insertExtraNode } = this.$props

View File

@ -83,6 +83,8 @@ const Affix = {
// Wait for parent component ref has its value
this.timeout = setTimeout(() => {
this.setTargetEventListeners(target)
// Mock Event object.
this.updatePosition({})
})
},
watch: {

View File

@ -2,15 +2,7 @@ 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', () => {
it('should scroll to top after click it', async () => {
const wrapper = mount(BackTop, {
propsData: {
visibilityHeight: -1,
@ -19,9 +11,9 @@ describe('BackTop', () => {
document.documentElement.scrollTop = 400
// trigger scroll manually
wrapper.vm.handleScroll()
jest.runAllTimers()
await new Promise(resolve => setTimeout(resolve, 0))
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)
})
})

View File

@ -77,7 +77,7 @@ describe('Carousel', () => {
sync: true,
}
const wrapper = mount(Carousel, props)
const onWindowResized = wrapper.vm.onWindowResized
const { onWindowResized } = wrapper.vm
const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel')
const spy2 = jest.spyOn(window, 'removeEventListener')
wrapper.destroy()