diff --git a/site/test.html b/site/test.html index 6a38bab..a122385 100644 --- a/site/test.html +++ b/site/test.html @@ -14,7 +14,8 @@

This will become an example when compiled

diff --git a/test/demo.cljs b/test/demo.cljs index cfd171b..1b8ec39 100644 --- a/test/demo.cljs +++ b/test/demo.cljs @@ -30,7 +30,7 @@ (defn src-for [defs] [:pre (-> defs src-for-names demoutil/syntaxify)]) -(defn demo-component [{:keys [comp defs]}] +(defn demo-component [{:keys [comp defs src]}] [:div (when comp [:div.demo-example @@ -38,7 +38,9 @@ [comp]]) [:div.demo-source [:h3.demo-heading "Source"] - (src-for defs)]]) + (if src + (demoutil/syntaxify src) + (src-for defs))]]) (defn simple-component [] [:div @@ -232,14 +234,37 @@ :defs [:ns :calc-bmi :bmi-data :set-bmi :slider :bmi-component]}]]) +(defn test-results [] + [:div + [:h2 "Test results"] + [runtests/test-output]]) + +(defn complete-simple-demo [] + [:div + [:h2 "Another demo"] + [demo-component {:comp simpleexample/simple-example + :src (get-source "simpleexample.cljs")}]]) + +(defn todomvc-demo [] + [:div + [:h2 "Todomvc"] + [demo-component {:comp todomvc/todo-app + :src (get-source "todomvc.cljs")}]]) + (defn demo [] - [:div.cloact-demo - [:h1 "This will become a demo"] - [intro] - [managing-state] - [essential-api] - [bmi-demo] - [:p "WIP"]]) + [:div + [:div.test-output-mini + [runtests/test-output-mini]] + [:div.cloact-demo + [:h1 "This will become a demo"] + [intro] + [managing-state] + [essential-api] + [bmi-demo] + [test-results] + [complete-simple-demo] + [todomvc-demo] + [:p "WIP"]]]) (defn ^:export mountdemo [] (cloact/render-component [demo] (.-body js/document))) diff --git a/test/runtests.cljs b/test/runtests.cljs index 7c69a69..2a7f5d2 100644 --- a/test/runtests.cljs +++ b/test/runtests.cljs @@ -4,9 +4,7 @@ :refer (is deftest with-test run-tests testing)] [cloact.debug :refer [dbg println]]) (:require [cemerick.cljs.test :as t] - [cloact.core :as cloact :refer [atom]] - [demo :as demo] - [todomvc :as todomvc])) + [cloact.core :as cloact :refer [atom]])) (defn ^:export console-print [x] (when (not= x "\n") @@ -34,23 +32,11 @@ " assertions.")] [:p (:fail res) " failues, " (:error res) " errors."]])])) -(defn examples [] - (let [p {:style {:color "#aaa"}}] - [:div.runtests - [demo/demo] - [:div - [:h2 p "Test results:"] - [test-output]] - [:div - [:h2 p "Simple example:"] - [simpleexample/simple-example]] - [:div - [:h2 p "Todomvc:"] - [todomvc/todo-app]]])) +(defn test-output-mini [] + (let [res @test-results] + (if res + (if (zero? (+ (:fail res) (:error res))) + [:div "Tests ok"] + [test-output]) + [:div "."]))) -(defn test-main [] - [examples]) - -(defn ^:export run [] - (cloact/render-component [test-main] - (.-body js/document)))