I'm trying to use the React Simulate function to simulate a mouseDown event for testing.
(defn mouse-down [node]
((.-mouseDown(.-Simulate ReactTestUtils) node (clj->js {:button 0})))
js translation:
ReactTestUtils.Simulate.mouseDown(node, {button: 0})
Nothing I've tried has resulted in an invocation of the mousedown listener--but when the listener is there when i try it in the browser where it works. It's just in the simulation.
What am I missing?
There are a couple mistakes in the Syntax here and your parens don't match. Generally it becomes easier if you reorganize the code a bit and
->can help there. As mentioned in the comment you want to use.mouseDowninstead of.-mouseDown. I opted to use#jsinstead ofclj->jssince that is more optimal for static js objects such as this.You can also make this a little more readable depending on where
ReactTestUtilsis coming from. I'm assuming its from thereact-dompackage which you just required.