From b2bfc14afbef4c9c0ee6c34f4ccb3adb196eb929 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Fri, 14 Feb 2014 11:27:45 +0100 Subject: [PATCH] Move test code for partial --- src/reagent/core.cljs | 6 ------ test/testcloact.cljs | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index a9d6e8e..a5cf48a 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -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)))) diff --git a/test/testcloact.cljs b/test/testcloact.cljs index 4aa3bf4..78b4e1d 100644 --- a/test/testcloact.cljs +++ b/test/testcloact.cljs @@ -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)))))