rare-sapphire
rare-sapphire2y ago

How to mock and test Selections

Hi. Im having a hard time on jest testing the Select. Is there a sample reference online? Thank you
6 Replies
refine-support-bot
Hi, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and found an answer! 🏆
Answer: Refer to the refine useSelect hook documentation for more information on how to mock and test Selections. SOURCES: ./docs/api-reference/core/hooks/useSelect/index.md

Note: If this is the answer you need, then we are very lucky. If not, please wait for someone from the refine core team or the community to try to help you.
xenial-black
xenial-black2y ago
Hi @thedevkim, can you give me more detail ? do you wanna test <Select> component from @pankod/refine-antd ?
rare-sapphire
rare-sapphireOP2y ago
Yes i want to test the <Select> component from @pankod/refine-antd Like, the selecting of options etc. @alicanerdurmaz
xenial-black
xenial-black2y ago
Unfortunately, I don't have a resource in mind that I can recommend for this. maybe other people in community can recommend. but i wanna clearify something. The select component is exported from antd without any changes. So every solution you apply for antd components is also valid for refine-antd
rare-sapphire
rare-sapphireOP2y ago
The issue im getting is that, testing the events for <Select> with fireEvent. Like selecting options etc. I want to fireEvent onChange of the <Select> component in jest. Do you have any ideas?
xenial-black
xenial-black2y ago
Unfortunately i have not 😕 if you ask on antd forums, probably you will get faster answer