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
|
||||
|
||||
> 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/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"]})
|
||||
|
|
|
@ -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