【发布时间】:2019-03-26 11:53:26
【问题描述】:
您好,我有以下代码,我需要在使用按钮和链接时更改窗口位置。
export default class CampaignAdSection extends Component {
constructor(props) {
super(props)
this.customiseClickable = this.customiseClickable.bind(this);
}
customiseClickable(e) {
this.props.history.push(`/customize/aus`);
}
render() {
let { packages, history, campaignDetails } = this.props;
return (
<div className="xs-text-center">
<button
type="button"
className="btn btn-primary pkg-adbtn"
onClick={e => this.customiseClickable(e)}
>
Trip
</button>{' '}
<b className="color-grey-secondary">
{' '}
or,{' '}
<Link
to={
`${
history.location.pathname.indexOf('request-callback') > 0
? history.location.pathname.split('request-callback')[0]
: history.location.pathname + '/'
}request-callback` +
`${history.location.search ? history.location.search : ''}`
}
className="tracker-talkbtn"
>
Expert
</Link>
</b>
</div>
);
}
}
根据我的代码,它一直在工作。但是我怎样才能为此添加规范?我是反应测试的初学者。能不能给点意见?
我想单击该按钮并检查位置是否已更改?
【问题讨论】:
标签: reactjs unit-testing jestjs