I'm learning react and having some problem in test file.
My code problem code is
<Button
id="direct-to-like"
onClick={() => VoteHandler('like')}
>
{like + (' like'.concat(like === 1 ? '' : 's'))}
</Button>
I used button in react bootstrap.
I had to test >> {like + (' like'.concat(like === 1 ? '' : 's'))} << This part. What it does is to handle like number. As newbie in react, I did some handler tests but could not find out test method for that part
it('like button clicked', () => {
const component = mount(articleDetail);
const wrapper = component.find('#direct-to-like').at(0);
wrapper.simulate('click');
expect(wrapper.length).toBe(1);
expect(spyPutVote).toHaveBeenCalledTimes(1);
});
Above is my original tests part for like button.
Aucun commentaire:
Enregistrer un commentaire