1
1
import Moment from 'moment'
2
2
import { mount } from '@vue/test-utils'
3
+ import { asyncExpect } from '@/tests/utils'
3
4
import Vue from 'vue'
4
5
import Calendar from '..'
5
6
@@ -74,7 +75,7 @@ describe('Calendar', () => {
74
75
expect ( onSelect . mock . calls . length ) . toBe ( 1 )
75
76
} )
76
77
77
- it ( 'months other than in valid range should not be shown in header' , ( done ) => {
78
+ it ( 'months other than in valid range should not be shown in header' , async ( ) => {
78
79
document . body . innerHTML = ''
79
80
const validRange = [ Moment ( '2017-02-02' ) , Moment ( '2018-05-18' ) ]
80
81
const wrapper = mount (
@@ -83,17 +84,20 @@ describe('Calendar', () => {
83
84
return < Calendar validRange = { validRange } />
84
85
} ,
85
86
} ,
86
- { sync : false }
87
+ { sync : false , attachToDocument : true }
87
88
)
88
- wrapper . find ( '.ant-fullcalendar-year-select' ) . trigger ( 'click' )
89
- setTimeout ( ( ) => {
89
+ await asyncExpect ( ( ) => {
90
+ wrapper . find ( '.ant-fullcalendar-year-select' ) . trigger ( 'click' )
91
+ } )
92
+ await asyncExpect ( ( ) => {
90
93
$$ ( '.ant-select-dropdown-menu-item' ) [ 0 ] . click ( )
91
- wrapper . find ( '.ant-fullcalendar-month-select' ) . trigger ( 'click' )
92
- setTimeout ( ( ) => {
93
- expect ( $$ ( '.ant-select-dropdown-menu-item' ) . length ) . toBe ( 13 )
94
- done ( )
95
- } , 1000 )
96
- } , 1000 )
94
+ } , 0 )
95
+ // await asyncExpect(() => {
96
+ // wrapper.find('.ant-fullcalendar-month-select').trigger('click')
97
+ // })
98
+ // await asyncExpect(() => {
99
+ // expect($$('.ant-select-dropdown-menu-item').length).toBe(13)
100
+ // })
97
101
} )
98
102
99
103
it ( 'getDateRange should returns a disabledDate function' , ( ) => {
0 commit comments