Merge pull request #19 from Day8/feature/tests
first run of travis and tests
This commit is contained in:
commit
1ba2a08957
|
@ -0,0 +1,6 @@
|
||||||
|
language: clojure
|
||||||
|
lein: lein2
|
||||||
|
script: "lein2 test"
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -qq rhino
|
|
@ -1,3 +1,5 @@
|
||||||
|
# re-frame [![Build Status](https://travis-ci.org/Day8/re-frame.png?branch=master)](https://travis-ci.org/Day8/reframe)
|
||||||
|
|
||||||
## On Derived Values
|
## On Derived Values
|
||||||
|
|
||||||
> This, milord, is my family's axe. We have owned it for almost nine hundred years, see. Of course,
|
> This, milord, is my family's axe. We have owned it for almost nine hundred years, see. Of course,
|
||||||
|
|
39
project.clj
39
project.clj
|
@ -6,35 +6,38 @@
|
||||||
[org.clojure/clojurescript "0.0-2760"]
|
[org.clojure/clojurescript "0.0-2760"]
|
||||||
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
|
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
|
||||||
[reagent "0.5.0-alpha3"]]
|
[reagent "0.5.0-alpha3"]]
|
||||||
|
|
||||||
:profiles {:debug {:debug true}
|
:profiles {:debug {:debug true}
|
||||||
:dev {:dependencies [[spellhouse/clairvoyant "0.0-48-gf5e59d3"]]
|
: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
|
:clean-targets [:target-path
|
||||||
"run/compiled/demo"]
|
"run/compiled/demo"]
|
||||||
|
|
||||||
:resource-paths ["run/resources"]
|
:resource-paths ["run/resources"]
|
||||||
:jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] ;;
|
:jvm-opts ["-Xmx1g" "-XX:+UseConcMarkSweepGC"] ;;
|
||||||
:source-paths ["src"]
|
:source-paths ["src"]
|
||||||
:test-paths ["test"]
|
:test-paths ["test"]
|
||||||
|
|
||||||
;; Exclude the demo code from the output of either:
|
;; Exclude the demo code from the output of either:
|
||||||
;; - lein jar
|
;; - lein jar
|
||||||
;; - lein install
|
;; - lein install
|
||||||
;; :jar-exclusions [#"(?:^|\/)re-frame-demo\/"]
|
;; :jar-exclusions [#"(?:^|\/)re-frame-demo\/"]
|
||||||
|
|
||||||
:cljsbuild {:builds [{:id "demo" ;; currently bogus, there is no demo or tests
|
:cljsbuild {:builds [{:id "test" ;; currently bogus, there is no demo or tests
|
||||||
:source-paths ["src"]
|
:source-paths ["test"]
|
||||||
:compiler {:output-to "run/compiled/demo.js"
|
:compiler {:output-to "run/compiled/test.js"
|
||||||
:source-map "run/compiled/demo.js.map"
|
:source-map "run/compiled/test.js.map"
|
||||||
:output-dir "run/compiled/demo"
|
:output-dir "run/compiled/test"
|
||||||
:optimizations :none
|
:optimizations :simple
|
||||||
:pretty-print true}}]}
|
:pretty-print true}}]
|
||||||
|
|
||||||
|
:test-commands {"rhino" ["rhino" "-opt" "-1" :rhino-runner
|
||||||
|
""
|
||||||
|
"run/compiled/test.js"]}}
|
||||||
|
|
||||||
:aliases {"auto" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "auto" "demo,"]
|
:aliases {"auto" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "auto" "demo,"]
|
||||||
"once" ["do" "clean," "cljsbuild" "clean," "cljsbuild" "once" "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"]})
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
|
@ -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)))))
|
Loading…
Reference in New Issue