Move test code for partial

This commit is contained in:
Dan Holmsand 2014-02-14 11:27:45 +01:00
parent effcbe6615
commit b2bfc14afb
2 changed files with 14 additions and 10 deletions

View File

@ -144,10 +144,4 @@ the result can be compared with ="
[f & args]
(util/partial-ifn. f args nil))
(let [p1 (partial vector 1 2)]
(assert (= (p1 3) [1 2 3]))
(assert (= p1 (partial vector 1 2)))
(assert (ifn? p1))
(assert (= (partial vector 1 2) p1))
(assert (not= p1 (partial vector 1 3))))

View File

@ -55,11 +55,13 @@
:render
(fn [this]
(let [props (reagent/props this)]
(assert (map? props))
(assert (= props ((reagent/argv this) 1)))
(is (map? props))
(is (= props ((reagent/argv this) 1)))
(is (= 1 (first (reagent/children this))))
(is (= 1 (count (reagent/children this))))
(swap! ran inc)
[:div (str "hi " (:foo props) ".")]))})]
(with-mounted-component (comp {:foo "you"})
(with-mounted-component (comp {:foo "you"} 1)
(fn [C div]
(swap! ran inc)
(is (found-in #"hi you" div))))
@ -128,7 +130,7 @@
v2 (atom 0)
c2 (fn [{val :val}]
(swap! ran inc)
(assert (= @v1 val))
(is (= @v1 val))
[:div @v2])
c1 (fn []
(swap! ran inc)
@ -300,3 +302,11 @@
(as-string ["div.foo.bar"])))
(is (re-find #"id=.foo"
(as-string ['div#foo.foo.bar]))))
(deftest partial-test []
(let [p1 (reagent/partial vector 1 2)]
(is (= (p1 3) [1 2 3]))
(is (= p1 (reagent/partial vector 1 2)))
(is (ifn? p1))
(is (= (reagent/partial vector 1 2) p1))
(is (not= p1 (reagent/partial vector 1 3)))))