I'm still in a learning phase for Cljs and Om. I'm looking into writing comopnent test. Some components have cljs-http calls to an API I created. When testing, I do not want those API calls to actually send the request, so I'm looking into mocking the request and returning a fixture. Here's an example component I have:
(defn async-component [data owner]
(reify
IWillMount
(will-mount [_]
(let [resp (go ((<! (cljs-http "/") :body))]
(om/update! data [:objects] resp)))
IRender
(render [_]
[:ul (apply map item-component data)])))
Please don't mind if the code is actually syntactically correct, I'm just showing the gist of it.
What I now want to do is test this component and the API call to see if it will render the fixture that I mock the request with. How is this done? I know cljs.test has the async block to test async code with, but all example show it testing actual code blocks that only have a go in it, not in a larger context.
Aucun commentaire:
Enregistrer un commentaire