From 1db9112a854106fdf9b8d2eff3db7b7b1a440ba0 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Wed, 8 Nov 2017 20:48:36 +0200 Subject: [PATCH] wip --- test/reagenttest/testreagent.cljs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index 5cb42f7..3f73496 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -1020,6 +1020,44 @@ (is (= "
" (rstr [:div [:input]])))) +#_ +(deftest test-input-value + (when r/is-client + (let [state (r/atom "") + ran (atom 0) + c (fn [] + (swap! ran inc) + [:input {:value @state + :on-change (fn [e] + (js/console.log e) + (reset! state (.. e -target -value)))}])] + (t/async done + (u/with-mounted-component-async [c] done + (fn [c div done] + (u/run-fns-after-render + (fn [] + (is (= "" (.-value (aget (.-children div) 0)))) + (is (= @ran 1)) + + (reset! state "foo")) + (fn [] + (is (= "foo" (.-value (aget (.-children div) 0)))) + (is (= @ran 2)) + + (set! (.-value (aget (.-children div) 0)) "bar") + (.dispatchEvent (aget (.-children div) 0) + (doto (.createEvent js/document "HTMLEvents") + (.initEvent "input" true false)))) + (fn [] + (is (= "bar" (.-value (aget (.-children div) 0)))) + (is (= "bar" @state)) + (is (= @ran 2))) + (fn [] + (is (= "bar" (.-value (aget (.-children div) 0)))) + (is (= "bar" @state)) + (is (= @ran 2))) + done))))))) + (deftest test-object-children (is (= "

foo bar1

" (rstr [:p 'foo " " :bar nil 1])))