'How to write Unit Test case for Switch Statement that returns Component in Jest with React Testing Library
When I writing test case, I was able to reach out to case 0, but not able to reach other 1
const tabContent = (isCurrent) => {
switch (isCurrent) {
case 0:
return <Component 1 />;
case 1:
return <Component 2 />;
default:
return null;
}
};
Solution 1:[1]
Then set isCurrent to 1 to go to the first case tabContent(1) Any other value wil go to the default
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Niek Bruins |
