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.
Asked
Active
Viewed 147 times
0

Rahul Dole
- 2,723
- 2
- 24
- 30
-
Which version of React day picker are you using? – c-chavez Oct 22 '18 at 14:13
-
Its v7.1.9. Should that matter? – Rahul Dole Oct 22 '18 at 19:18
1 Answers
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