对于我有一个文本框的组件,我需要能够从测试中更改其中的文本:
(defn choose-city-component []
(let [inner-state (r/atom {:text ""})]
(fn []
[:div
[:input#txt_city {
:type "text"
:value (@inner-state :text)
:on-change #(swap! inner-state assoc :text (-> % .-target .-value))...
在测试中,我将它呈现在屏幕上:
(deftest choose-city-component-test-out
;;GIVEN render component in test
(let [comp (r/render-component [w/choose-city-component]
(. js/document (getElementById "test")))]
;;WHEN changing the city....
现在使用 jQuery 触发器,我正在尝试在文本上模拟 onChange:
我们尝试了
(.change ($ :#txt_city) {"target" {"value" "Paris"}})
和
(.trigger ($ :#txt_city) "change" {"target" {"value" "Paris"}}))
但它不起作用...