return (
<div className={`${classes.root} multiSelectElement`}>
<Select
classes={classes}
styles={selectStyles}
inputId="react-select-multiple"
closeMenuOnSelect={false}
TextFieldProps={{
label: props.label,
InputLabelProps: {
htmlFor: 'react-select-multiple',
shrink: true,
className: classes.label,
},
}}
placeholder={props.placeholder}
options={listElements}
components={components}
value={props.value}
onChange={props.handleChange}
isMulti
/>
</div>
);
在给定的代码片段中,我不确定在找到props
之后如何传递模拟的component
(属性名称为Select
),如下所示:
it('renders select', () => {
const componentsMock = {
Control: jest.fn(),
Menu: jest.fn(),
MultiValue: jest.fn(),
NoOptionsMessage: jest.fn(),
Option: jest.fn(),
Placeholder: jest.fn(),
SingleValue: jest.fn(),
ValueContainer: jest.fn(),
};
const listElements = [
];
const wrapper = mount(<Multiselect list={listElements} />);
let wrapper2 = wrapper.find(Select).simulate('mouseDown');
});