我有以下成分,我正在使用酶和胶带来测试反应成分。
class Modal extends Component {
constructor(props) {
super(props);
this.onAccountChange = this.onAccountChange.bind(this);
this.state = {
selectedAccount: props.accounts[0].id;
};
}
render() {
const {accounts} = this.props;
return <div>
<select className="account-selector" onChange={this.onAccountChange}>
{accounts.map(account => <option key={account.id} value={account.id}>{account.desc}</option>)}
</select>
</div>;
}
onAccountChange(e){
const {value: selectedAccount} = e.target;
this.setState({selectedAccount});
}
我怎样才能测试select元素中的OnChange以及它调用onAccountChange的函数?