-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hi there, I am trying to utilize cljs-react-test and dommy to change a dropdown menu choice which in turns updates the atom. However, it seems I am not doing this correctly. Here is what I have for code and my tests.
------ Component --------- in (ns. component.dropdown)
(defn dropdown [] [:div [:select {:on-change #(swap! app-state assoc :bind (.. % -target -value))} [:option {:value "1"} "1"] [:option {:value "2"} "2"] [:option {:value "3"} "3"] [:option {:value "4"} "4"]]])
------In Test file ------------
`(def ^:dynamic c)
(use-fixtures :each (fn [test-fn]
(binding [c (tu/new-container!)]
(test-fn)
(tu/unmount! c))))
(deftest dropdown-selection-appstate-on-change
(let [_ (reagent/render [cd/dropdown app-state] c)
node (sel1 c [:select])
dropdown-selection (:bind @App-State)]
(is (= "0" (:bind @App-State)))
(sim/change node {:target {:option {:value "3"}}})
(is (= "3" (:bind @App-State)))))`
----------Test read out-----------
FAIL in (dropdown-selection-appstate-on-change) (:)
expected: (= "3" (:bind (clojure.core/deref app-state)))
actual: (not (= "3" nil))