File tree Expand file tree Collapse file tree 4 files changed +7
-13
lines changed Expand file tree Collapse file tree 4 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ export default {
117
117
} ,
118
118
119
119
resetEffect ( node ) {
120
- if ( ! node || node === this . extraNode ) {
120
+ if ( ! node || node === this . extraNode || ! ( node instanceof Element ) ) {
121
121
return
122
122
}
123
123
const { insertExtraNode } = this . $props
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ const Affix = {
83
83
// Wait for parent component ref has its value
84
84
this . timeout = setTimeout ( ( ) => {
85
85
this . setTargetEventListeners ( target )
86
+ // Mock Event object.
87
+ this . updatePosition ( { } )
86
88
} )
87
89
} ,
88
90
watch : {
Original file line number Diff line number Diff line change @@ -2,15 +2,7 @@ import { mount } from '@vue/test-utils'
2
2
import BackTop from '..'
3
3
4
4
describe ( 'BackTop' , ( ) => {
5
- beforeAll ( ( ) => {
6
- jest . useFakeTimers ( )
7
- } )
8
-
9
- afterAll ( ( ) => {
10
- jest . useRealTimers ( )
11
- } )
12
-
13
- it ( 'should scroll to top after click it' , ( ) => {
5
+ it ( 'should scroll to top after click it' , async ( ) => {
14
6
const wrapper = mount ( BackTop , {
15
7
propsData : {
16
8
visibilityHeight : - 1 ,
@@ -19,9 +11,9 @@ describe('BackTop', () => {
19
11
document . documentElement . scrollTop = 400
20
12
// trigger scroll manually
21
13
wrapper . vm . handleScroll ( )
22
- jest . runAllTimers ( )
14
+ await new Promise ( resolve => setTimeout ( resolve , 0 ) )
23
15
wrapper . find ( '.ant-back-top' ) . trigger ( 'click' )
24
- jest . runAllTimers ( )
16
+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
25
17
expect ( Math . abs ( Math . round ( document . documentElement . scrollTop ) ) ) . toBe ( 0 )
26
18
} )
27
19
} )
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ describe('Carousel', () => {
77
77
sync : true ,
78
78
}
79
79
const wrapper = mount ( Carousel , props )
80
- const onWindowResized = wrapper . vm . onWindowResized
80
+ const { onWindowResized } = wrapper . vm
81
81
const spy = jest . spyOn ( wrapper . vm . onWindowResized , 'cancel' )
82
82
const spy2 = jest . spyOn ( window , 'removeEventListener' )
83
83
wrapper . destroy ( )
You can’t perform that action at this time.
0 commit comments