简体   繁体   中英

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; } };

Then set isCurrent to 1 to go to the first case tabContent(1) Any other value wil go to the default

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM