bensu / cljs-react-test

A ClojureScript wrapper around Reacts Test Utilities
43 stars 7 forks source link

Trying to select (w/ Dommy) nested :option #9

Open Wolfgang51 opened 6 years ago

Wolfgang51 commented 6 years ago

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))