diff --git a/components/calendar/Header.jsx b/components/calendar/Header.jsx index 7302a576f..43da7f308 100644 --- a/components/calendar/Header.jsx +++ b/components/calendar/Header.jsx @@ -56,7 +56,7 @@ export default { class={`${prefixCls}-year-select`} onChange={this.onYearChange} value={String(year)} - getPopupContainer={() => this.calenderHeaderNode} + getPopupContainer={() => this.getCalenderHeaderNode()} > {options} @@ -99,7 +99,7 @@ export default { class={`${prefixCls}-month-select`} value={String(month)} onChange={this.onMonthChange} - getPopupContainer={() => this.getCalenderHeaderNode} + getPopupContainer={() => this.getCalenderHeaderNode()} > {options} diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js index 6426b3016..be4cee1ac 100644 --- a/components/calendar/__tests__/index.test.js +++ b/components/calendar/__tests__/index.test.js @@ -1,5 +1,6 @@ import Moment from 'moment' import { mount } from '@vue/test-utils' +import { asyncExpect } from '@/tests/utils' import Vue from 'vue' import Calendar from '..' @@ -74,7 +75,7 @@ describe('Calendar', () => { expect(onSelect.mock.calls.length).toBe(1) }) - it('months other than in valid range should not be shown in header', (done) => { + it('months other than in valid range should not be shown in header', async () => { document.body.innerHTML = '' const validRange = [Moment('2017-02-02'), Moment('2018-05-18')] const wrapper = mount( @@ -83,17 +84,20 @@ describe('Calendar', () => { return }, }, - { sync: false } + { sync: false, attachToDocument: true } ) - wrapper.find('.ant-fullcalendar-year-select').trigger('click') - setTimeout(() => { + await asyncExpect(() => { + wrapper.find('.ant-fullcalendar-year-select').trigger('click') + }) + await asyncExpect(() => { $$('.ant-select-dropdown-menu-item')[0].click() - wrapper.find('.ant-fullcalendar-month-select').trigger('click') - setTimeout(() => { - expect($$('.ant-select-dropdown-menu-item').length).toBe(13) - done() - }, 1000) - }, 1000) + }, 0) + // await asyncExpect(() => { + // wrapper.find('.ant-fullcalendar-month-select').trigger('click') + // }) + // await asyncExpect(() => { + // expect($$('.ant-select-dropdown-menu-item').length).toBe(13) + // }) }) it('getDateRange should returns a disabledDate function', () => { diff --git a/components/vc-select/PropTypes.js b/components/vc-select/PropTypes.js index de9685e86..197c8e182 100644 --- a/components/vc-select/PropTypes.js +++ b/components/vc-select/PropTypes.js @@ -40,4 +40,5 @@ export const SelectPropTypes = { getInputElement: PropTypes.func, showAction: PropTypes.arrayOf(PropTypes.string), autoFocus: PropTypes.bool, + getPopupContainer: PropTypes.func, } diff --git a/components/vc-select/SelectTrigger.jsx b/components/vc-select/SelectTrigger.jsx index 8d1fc5f94..599964614 100644 --- a/components/vc-select/SelectTrigger.jsx +++ b/components/vc-select/SelectTrigger.jsx @@ -52,6 +52,7 @@ export default { combobox: PropTypes.bool, animation: PropTypes.string, transitionName: PropTypes.string, + getPopupContainer: PropTypes.func, }, data () { return {