Merge pull request #19 from Day8/feature/tests

first run of travis and tests
This commit is contained in:
Stuart Mitchell 2015-03-05 12:28:22 +13:00
commit 1ba2a08957
4 changed files with 60 additions and 18 deletions

6
.travis.yml Normal file
View File

@ -0,0 +1,6 @@
language: clojure
lein: lein2
script: "lein2 test"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq rhino

View File

@ -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,

View File

@ -9,7 +9,8 @@
: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
@ -25,16 +26,18 @@
;; - 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"]})

View File

@ -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)))))