2018-01-04 20:43:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
2017-11-19 01:41:40 +08:00
|
|
|
import Select from '..';
|
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
|
|
|
|
|
|
|
describe('Select', () => {
|
|
|
|
focusTest(Select);
|
2018-01-04 20:43:56 +08:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.useFakeTimers();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
jest.useRealTimers();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have default notFoundContent', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Select mode="multiple" />
|
|
|
|
);
|
|
|
|
wrapper.find('.ant-select').simulate('click');
|
|
|
|
jest.runAllTimers();
|
|
|
|
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
|
|
|
|
expect(dropdownWrapper.find('MenuItem').length).toBe(1);
|
|
|
|
expect(dropdownWrapper.find('MenuItem').at(0).text()).toBe('Not Found');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support set notFoundContent to null', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Select mode="multiple" notFoundContent={null} />
|
|
|
|
);
|
|
|
|
wrapper.find('.ant-select').simulate('click');
|
|
|
|
jest.runAllTimers();
|
|
|
|
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
|
|
|
|
expect(dropdownWrapper.find('MenuItem').length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not have default notFoundContent when mode is combobox', () => {
|
|
|
|
const wrapper = mount(
|
2018-06-19 17:10:35 +08:00
|
|
|
<Select mode={Select.COMBOBOX_MODE} />
|
2018-01-04 20:43:56 +08:00
|
|
|
);
|
|
|
|
wrapper.find('.ant-select').simulate('click');
|
|
|
|
jest.runAllTimers();
|
|
|
|
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
|
|
|
|
expect(dropdownWrapper.find('MenuItem').length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not have notFoundContent when mode is combobox and notFoundContent is set', () => {
|
|
|
|
const wrapper = mount(
|
2018-06-19 17:10:35 +08:00
|
|
|
<Select mode={Select.COMBOBOX_MODE} notFoundContent="not at all" />
|
2018-01-04 20:43:56 +08:00
|
|
|
);
|
|
|
|
wrapper.find('.ant-select').simulate('click');
|
|
|
|
jest.runAllTimers();
|
|
|
|
const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent());
|
|
|
|
expect(dropdownWrapper.find('MenuItem').length).toBe(1);
|
|
|
|
expect(dropdownWrapper.find('MenuItem').at(0).text()).toBe('not at all');
|
|
|
|
});
|
2017-11-19 01:41:40 +08:00
|
|
|
});
|