2015-09-14 07:09:04 +00:00
|
|
|
(ns ^:figwheel-always
|
|
|
|
reagenttest.runtests
|
2015-02-10 13:18:56 +00:00
|
|
|
(:require [reagenttest.testreagent]
|
|
|
|
[reagenttest.testcursor]
|
|
|
|
[reagenttest.testinterop]
|
|
|
|
[reagenttest.testratom]
|
2015-09-12 16:34:10 +00:00
|
|
|
[reagenttest.testratomasync]
|
2015-09-19 17:03:29 +00:00
|
|
|
[reagenttest.testtrack]
|
2015-02-10 13:18:56 +00:00
|
|
|
[reagenttest.testwrap]
|
2015-01-31 22:09:42 +00:00
|
|
|
[cljs.test :as test :include-macros true]
|
2015-07-31 13:13:27 +00:00
|
|
|
[reagent.core :as r]
|
2014-11-29 22:26:42 +00:00
|
|
|
[reagent.interop :refer-macros [.' .!]]
|
2015-02-10 17:20:48 +00:00
|
|
|
[reagent.debug :refer-macros [dbg log]]
|
|
|
|
[reagentdemo.core :as demo]))
|
2015-01-31 22:09:42 +00:00
|
|
|
|
2014-11-29 22:47:57 +00:00
|
|
|
(enable-console-print!)
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2015-07-31 13:13:27 +00:00
|
|
|
(def test-results (r/atom nil))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2015-02-10 17:20:48 +00:00
|
|
|
(def test-box-style {:position 'absolute
|
|
|
|
:margin-left -35
|
|
|
|
:color :#aaa})
|
|
|
|
|
|
|
|
(defn all-tests []
|
|
|
|
(test/run-all-tests #"reagenttest.test.*"))
|
|
|
|
|
2015-02-10 13:18:56 +00:00
|
|
|
(defmethod test/report [::test/default :summary] [m]
|
|
|
|
;; ClojureScript 2814 doesn't return anything from run-tests
|
|
|
|
(reset! test-results m)
|
|
|
|
(println "\nRan" (:test m) "tests containing"
|
|
|
|
(+ (:pass m) (:fail m) (:error m)) "assertions.")
|
|
|
|
(println (:fail m) "failures," (:error m) "errors."))
|
|
|
|
|
2014-01-06 18:16:53 +00:00
|
|
|
(defn test-output-mini []
|
|
|
|
(let [res @test-results]
|
2015-02-10 17:20:48 +00:00
|
|
|
[:div {:style test-box-style}
|
|
|
|
(if res
|
|
|
|
(if (zero? (+ (:fail res) (:error res)))
|
|
|
|
"All tests ok"
|
|
|
|
[:span "Test failure: "
|
|
|
|
(:fail res) " failures, " (:error res) " errors."])
|
|
|
|
"testing")]))
|
|
|
|
|
|
|
|
(defn run-tests []
|
|
|
|
(reset! test-results nil)
|
2015-07-31 13:13:27 +00:00
|
|
|
(if r/is-client
|
2015-02-10 17:20:48 +00:00
|
|
|
(js/setTimeout all-tests 100)
|
|
|
|
(all-tests)))
|
|
|
|
|
2015-03-21 12:53:37 +00:00
|
|
|
(defn init! []
|
|
|
|
(when (some? (test/deftest empty-test))
|
|
|
|
;; Only run with :load-tests true
|
|
|
|
(reset! demo/test-results [#'test-output-mini])
|
|
|
|
(run-tests)))
|
|
|
|
|
2015-05-31 09:51:11 +00:00
|
|
|
(defn reload []
|
2015-09-14 07:09:04 +00:00
|
|
|
(demo/init!))
|
2015-05-31 09:51:11 +00:00
|
|
|
|
2015-03-21 12:53:37 +00:00
|
|
|
(init!)
|