From e0b8bd337be1e52c414e3c1bd054d091be15053b Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Sat, 14 Oct 2017 13:06:10 +0300 Subject: [PATCH] No need to mount test divs to dom --- test/reagenttest/testreagent.cljs | 12 ++---------- test/reagenttest/testwrap.cljs | 19 +++++++------------ 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index cedac5a..be78dfa 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -24,23 +24,15 @@ (def rflush r/flush) -(defn add-test-div [name] - (let [doc js/document - body (.-body js/document) - div (.createElement doc "div")] - (.appendChild body div) - div)) - (defn with-mounted-component [comp f] (when isClient - (let [div (add-test-div "_testreagent")] + (let [div (.createElement js/document "div")] (try (let [c (r/render comp div)] (f c div)) (finally (r/unmount-component-at-node div) - (r/flush) - (.removeChild (.-body js/document) div)))))) + (r/flush)))))) (defn found-in [re div] (let [res (.-innerHTML div)] diff --git a/test/reagenttest/testwrap.cljs b/test/reagenttest/testwrap.cljs index ae229ad..f366117 100644 --- a/test/reagenttest/testwrap.cljs +++ b/test/reagenttest/testwrap.cljs @@ -3,20 +3,15 @@ [reagent.debug :refer-macros [dbg println log]] [reagent.core :as r])) -(defn add-test-div [name] - (let [doc js/document - body (.-body js/document) - div (.createElement doc "div")] - (.appendChild body div) - div)) - (defn with-mounted-component [comp f] (when r/is-client - (let [div (add-test-div "_testreagent")] - (let [comp (r/render comp div #(f comp div))] - (r/unmount-component-at-node div) - (r/flush) - (.removeChild (.-body js/document) div))))) + (let [div (.createElement js/document "div")] + (try + (let [c (r/render comp div)] + (f c div)) + (finally + (r/unmount-component-at-node div) + (r/flush)))))) (defn found-in [re div] (let [res (.-innerHTML div)]