Unit testing React functional component with jest and Enzyme

In my current company I am unit testing React components using jest and enzyme. While testing one of the functional components I came across a problem which needed a good solution/explanation and after some research on it I think I found the right way to do it and I wanted to share it with the community

Password strength indicator: Develop component to show the user how strong is the password in React js

When the user enters the password, he/she should be able to see a bar which shows indicates the strength of the password entered in the field. Red color means it’s a weak password, Orange color means the password has medium strength and Green color means the password is strong enough!