diff --git a/.gitignore b/.gitignore index f952619..9e60517 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ **/target/ **/.nrepl-port +**/.nrepl-history /out /.serverless **/node_modules diff --git a/functions/boot.properties b/functions/boot.properties index 9def54a..2684c4d 100644 --- a/functions/boot.properties +++ b/functions/boot.properties @@ -1,5 +1,5 @@ #http://boot-clj.com #Mon Aug 15 22:32:43 CEST 2016 BOOT_CLOJURE_NAME=org.clojure/clojure -BOOT_CLOJURE_VERSION=1.9.0-alpha10 +BOOT_CLOJURE_VERSION=1.9.0-alpha14 BOOT_VERSION=2.6.0 diff --git a/functions/build.boot b/functions/build.boot index c868c41..80b4489 100644 --- a/functions/build.boot +++ b/functions/build.boot @@ -2,11 +2,11 @@ :resource-paths #{"src"} :dependencies '[[adzerk/boot-cljs "1.7.228-1" :scope "test"] [adzerk/boot-cljs-repl "0.3.3" :scope "test"] - [adzerk/boot-reload "0.4.12" :scope "test"] + [adzerk/boot-reload "0.4.12" :scope "test"] [pandeiro/boot-http "0.7.3" :scope "test"] [crisptrutski/boot-cljs-test "0.3.0-SNAPSHOT" :scope "test"] [boot-codox "0.10.0" :scope "test"] - [org.clojure/clojure "1.9.0-alpha12"] + [org.clojure/clojure "1.9.0-alpha14"] [org.clojure/core.async "0.2.391"] [org.clojure/test.check "0.9.0"] [org.clojure/clojurescript "1.9.229"] @@ -20,15 +20,30 @@ '[adzerk.boot-cljs :refer [cljs]] '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]] '[adzerk.boot-reload :refer [reload]] + '[crisptrutski.boot-cljs-test :refer [test-cljs]] '[codox.boot :refer [codox]] '[pandeiro.boot-http :refer [serve]]) +(deftask testing [] + (merge-env! :resource-paths #{"test"}) + identity) + +(deftask auto-test [] + (comp (testing) + (watch) + (speak) + (test-cljs))) + (deftask build [] (task-options! cljs {:compiler-options {:optimizations :simple :target :nodejs}}) (comp (cljs) (target))) +(deftask test [] + (comp (testing) + (test-cljs))) + (deftask dev [] (comp (watch) (checkout) diff --git a/functions/test/app/sample_test.cljs b/functions/test/app/sample_test.cljs new file mode 100644 index 0000000..1e8b158 --- /dev/null +++ b/functions/test/app/sample_test.cljs @@ -0,0 +1,32 @@ +(ns app.sample-test + (:require [clojure.test.check :as tc] + [clojure.test.check.generators :as gen] + [clojure.test.check.properties :as prop :include-macros true] + [cljs.spec :as s] + [cljs.spec.test :as stest] + [cljs.test :refer-macros [deftest is]] + [clojure.pprint :as pprint])) + +(def sort-idempotent-prop + (prop/for-all [v (gen/vector gen/int)] + (= (sort v) (sort (sort v))))) + +(tc/quick-check 100 sort-idempotent-prop) + +;; Sample function and a function spec +(defn fooo [i] (+ i 20)) + +(s/fdef fooo + :args (s/cat :i integer?) + :ret integer? + :fn #(> (:ret %) (-> % :args :i))) + +;; Utility functions to intergrate clojure.spec.test/check with clojure.test +(defn summarize-results' [spec-check] + (map (comp #(pprint/write % :stream nil) stest/abbrev-result) spec-check)) + +(defn check' [spec-check] + (is (nil? (-> spec-check first :failure)) (summarize-results' spec-check))) + +;; Tests +(deftest fooish (check' (stest/check `fooo)))