0

I'm using React day picker and trying to write some tests for it. One of the tests includes simulating click on a particular day and then checking the class name of that day whether it has added the selected class to it or not. But the problem is, the class name doesn't change at all even after simulating click through enzyme's method simulate('click'). The on click handler does get called though, and I can see in the console output which day was clicked.

Rahul Dole
  • 2,723
  • 2
  • 24
  • 30

1 Answers1

0

Figured out! The problem was I was checking the resultant html for the updated class name using the debug() method. But I realised that by using html() I could get the latest updated result. However, for actually checking the existence of the selected class, I couldn't simply use hasClass(<className>), instead I had to use .render().hasClass(<className>).

In short, the click event was working as expected, but just that the checking out output had to be done differently.

Rahul Dole
  • 2,723
  • 2
  • 24
  • 30