2013-12-16 22:19:36 +00:00
|
|
|
|
|
|
|
(ns runtests
|
2014-01-25 16:02:58 +00:00
|
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
2014-04-01 17:50:28 +00:00
|
|
|
[reagent.interop :refer-macros [.' .! fvar]]
|
2014-01-25 16:02:58 +00:00
|
|
|
[reagent.debug :refer-macros [dbg println]]
|
|
|
|
[demo :as demo]
|
|
|
|
[cemerick.cljs.test :as t]))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2014-01-24 10:03:01 +00:00
|
|
|
(enable-console-print!)
|
2013-12-16 22:19:36 +00:00
|
|
|
|
|
|
|
(def test-results (atom nil))
|
|
|
|
|
|
|
|
(defn test-output []
|
|
|
|
(let [res @test-results]
|
2014-01-24 10:03:01 +00:00
|
|
|
[:div {:style {:margin-top "40px"}}
|
2013-12-16 22:19:36 +00:00
|
|
|
(if-not res
|
|
|
|
[:div "waiting for tests to run"]
|
|
|
|
[:div
|
|
|
|
[:p (str "Ran " (:test res) " tests containing "
|
|
|
|
(+ (:pass res) (:fail res) (:error res))
|
|
|
|
" assertions.")]
|
2014-03-18 12:09:55 +00:00
|
|
|
[:p (:fail res) " failures, " (:error res) " errors."]])]))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2014-01-06 18:16:53 +00:00
|
|
|
(defn test-output-mini []
|
|
|
|
(let [res @test-results]
|
|
|
|
(if res
|
|
|
|
(if (zero? (+ (:fail res) (:error res)))
|
|
|
|
[:div "Tests ok"]
|
|
|
|
[test-output])
|
|
|
|
[:div "."])))
|
|
|
|
|
2014-01-10 10:49:36 +00:00
|
|
|
(defn test-demo []
|
|
|
|
[:div
|
|
|
|
[test-output]
|
|
|
|
[demo/demo]])
|
|
|
|
|
|
|
|
(defn ^:export mounttests []
|
2014-03-18 15:43:19 +00:00
|
|
|
(reagent/render-component (fn [] [test-demo])
|
|
|
|
(.-body js/document)))
|
2014-01-25 16:02:58 +00:00
|
|
|
|
|
|
|
(defn ^:export run-all-tests []
|
|
|
|
(println "-----------------------------------------")
|
|
|
|
(try
|
|
|
|
(reset! test-results (t/run-all-tests))
|
|
|
|
(catch js/Object e
|
|
|
|
(do
|
|
|
|
(println "Testrun failed\n" e "\n" (.-stack e))
|
|
|
|
(reset! test-results {:error e}))))
|
|
|
|
(println "-----------------------------------------"))
|
|
|
|
|
|
|
|
(if reagent/is-client
|
2014-03-18 12:09:55 +00:00
|
|
|
(do
|
|
|
|
(reset! test-results nil)
|
|
|
|
(js/setTimeout run-all-tests 1000))
|
2014-01-25 16:02:58 +00:00
|
|
|
(run-all-tests))
|