4
我有下面的例子組件酶檢查複選框狀態
export default class Header extends Component{
render(){
let activeStyle = {"backgroundColor": "green"};
let inActiveStyle = {"backgroundColor": "red"};
return(
<div className="profile-header" style={(this.props.active)?
activeStyle:inActiveStyle}>
<input type="checkbox" checked={this.props.active} readOnly/>
</div>
);
}
}
使用酶和薛寶釵我想斷言,對於
this.props.active = true
的的backgroundColor是綠色複選框被選中。
這裏是我的測試案例
describe('<Header />',() => {
it('valid component',() => {
const wrapper = shallow(<ProfileHeader
active= {true}
/>);
????
});
但我怎麼能斷言這兩種情況?