From f62bb1a32496632d22e9a0c3a13d8b3c5bbae942 Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Wed, 4 Mar 2015 17:12:54 +1300 Subject: [PATCH 1/3] first run of travis and tests --- .travis.yml | 6 ++++++ project.clj | 39 +++++++++++++++++++---------------- test/re-frame/middleware.cljs | 31 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 .travis.yml create mode 100644 test/re-frame/middleware.cljs diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c50d466 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: clojure +lein: lein2 +script: "lein2 test" +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq rhino \ No newline at end of file diff --git a/project.clj b/project.clj index 2197ddb..4624c8c 100644 --- a/project.clj +++ b/project.clj @@ -6,35 +6,38 @@ [org.clojure/clojurescript "0.0-2760"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [reagent "0.5.0-alpha3"]] - + :profiles {:debug {:debug true} :dev {:dependencies [[spellhouse/clairvoyant "0.0-48-gf5e59d3"]] - :plugins [[lein-cljsbuild "1.0.4"]]}} - - + :plugins [[lein-cljsbuild "1.0.4"] + [com.cemerick/clojurescript.test "0.3.3"]]}} + + :clean-targets [:target-path "run/compiled/demo"] - + :resource-paths ["run/resources"] :jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] ;; :source-paths ["src"] :test-paths ["test"] - + ;; Exclude the demo code from the output of either: ;; - lein jar ;; - lein install ;; :jar-exclusions [#"(?:^|\/)re-frame-demo\/"] - - :cljsbuild {:builds [{:id "demo" ;; currently bogus, there is no demo or tests - :source-paths ["src"] - :compiler {:output-to "run/compiled/demo.js" - :source-map "run/compiled/demo.js.map" - :output-dir "run/compiled/demo" - :optimizations :none - :pretty-print true}}]} - + + :cljsbuild {:builds [{:id "test" ;; currently bogus, there is no demo or tests + :source-paths ["test"] + :compiler {:output-to "run/compiled/test.js" + :source-map "run/compiled/test.js.map" + :output-dir "run/compiled/test" + :optimizations :simple + :pretty-print true}}] + + :test-commands {"rhino" ["rhino" "-opt" "-1" :rhino-runner + "" + "run/compiled/test.js"]}} + :aliases {"auto" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "auto" "demo,"] "once" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "once" "demo,"] - ;"test" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "auto" "test"] - } - ) + "test" ["do" "clean," "cljsbuild" "once," "cljsbuild" "test" "rhino"]}) diff --git a/test/re-frame/middleware.cljs b/test/re-frame/middleware.cljs new file mode 100644 index 0000000..2dad921 --- /dev/null +++ b/test/re-frame/middleware.cljs @@ -0,0 +1,31 @@ +(ns re-frame.test.middleware + (:require-macros [cemerick.cljs.test :refer (is deftest)]) + (:require [cemerick.cljs.test :as t] + [reagent.ratom :refer [atom]] + [re-frame.middleware :as middleware])) + +(enable-console-print!) + +(deftest pure + (let [db (atom {:a true}) + handler (fn [db [_ key value]] + (assoc db key value))] + ((middleware/pure handler) db [nil :a false]) + (is (= (:a @db) false)))) + +(deftest trim-v + (let [handler (fn [db vect] vect)] + (is (= (handler nil [:a :b :c]) + [:a :b :c])) + (is (= ((middleware/trim-v handler) nil [:a :b :c]) + [:b :c])))) + +(deftest path + (let [db {:a true} + handler (fn + [a [_]] + (not a))] + (let [new-db (((middleware/path [:a]) + handler) db [nil])] + (is (= (:a new-db) + false))))) From 8e88449815c337afdd70bc42c6ebcfeecc9e2fb7 Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Wed, 4 Mar 2015 17:41:22 +1300 Subject: [PATCH 2/3] badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e3fd91f..367a0ff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[img https://travis-ci.org/Day8/re-frame.svg] + ## On Derived Values > This, milord, is my family's axe. We have owned it for almost nine hundred years, see. Of course, From 4ade2b48c5481315c1ea997f1757e55eeeea644e Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Thu, 5 Mar 2015 10:58:43 +1300 Subject: [PATCH 3/3] a working badge! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 367a0ff..65c37e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[img https://travis-ci.org/Day8/re-frame.svg] +# re-frame [![Build Status](https://travis-ci.org/Day8/re-frame.png?branch=master)](https://travis-ci.org/Day8/reframe) ## On Derived Values