No need to mount test divs to dom

This commit is contained in:
Juho Teperi 2017-10-14 13:06:10 +03:00
parent 36509f79ff
commit e0b8bd337b
2 changed files with 9 additions and 22 deletions

View File

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

View File

@ -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))]
(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)]