[英]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当我编写测试用例时,我能够接触到案例 0,但无法接触到其他案例 1
const tabContent = (isCurrent) => { switch (isCurrent) { case 0: return <Component 1 />; case 1: return <Component 2 />; default: return null; } };
Then set isCurrent to 1 to go to the first case tabContent(1) Any other value wil go to the default然后将 isCurrent 设置为 1 将 go 设置为第一种情况 tabContent(1) 任何其他值将 go 设置为默认值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.