diff --git a/components/_util/wave.jsx b/components/_util/wave.jsx index ac262e156..396d5d5bc 100644 --- a/components/_util/wave.jsx +++ b/components/_util/wave.jsx @@ -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 diff --git a/components/affix/index.jsx b/components/affix/index.jsx index a9fb0b25b..56df9af4f 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -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: { diff --git a/components/back-top/__tests__/index.test.js b/components/back-top/__tests__/index.test.js index 803b7d5e6..caddee20f 100644 --- a/components/back-top/__tests__/index.test.js +++ b/components/back-top/__tests__/index.test.js @@ -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) }) }) diff --git a/components/carousel/__tests__/index.test.js b/components/carousel/__tests__/index.test.js index 03e17e5fb..d5a19c066 100644 --- a/components/carousel/__tests__/index.test.js +++ b/components/carousel/__tests__/index.test.js @@ -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()