Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit 517771a

Browse files
committed
Set up sample test
1 parent 238d0dc commit 517771a

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

functions/build.boot

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:resource-paths #{"src"}
33
:dependencies '[[adzerk/boot-cljs "1.7.228-1" :scope "test"]
44
[adzerk/boot-cljs-repl "0.3.3" :scope "test"]
5-
[adzerk/boot-reload "0.4.12" :scope "test"]
5+
[adzerk/boot-reload "0.4.12" :scope "test"]
66
[pandeiro/boot-http "0.7.3" :scope "test"]
77
[crisptrutski/boot-cljs-test "0.3.0-SNAPSHOT" :scope "test"]
88
[boot-codox "0.10.0" :scope "test"]
@@ -20,15 +20,30 @@
2020
'[adzerk.boot-cljs :refer [cljs]]
2121
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
2222
'[adzerk.boot-reload :refer [reload]]
23+
'[crisptrutski.boot-cljs-test :refer [test-cljs]]
2324
'[codox.boot :refer [codox]]
2425
'[pandeiro.boot-http :refer [serve]])
2526

27+
(deftask testing []
28+
(merge-env! :resource-paths #{"test"})
29+
identity)
30+
31+
(deftask auto-test []
32+
(comp (testing)
33+
(watch)
34+
(speak)
35+
(test-cljs)))
36+
2637
(deftask build []
2738
(task-options! cljs {:compiler-options {:optimizations :simple
2839
:target :nodejs}})
2940
(comp (cljs)
3041
(target)))
3142

43+
(deftask test []
44+
(comp (testing)
45+
(test-cljs)))
46+
3247
(deftask dev []
3348
(comp (watch)
3449
(checkout)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(ns app.sample-test
2+
(:require [clojure.test.check :as tc]
3+
[clojure.test.check.generators :as gen]
4+
[clojure.test.check.properties :as prop :include-macros true]
5+
[cljs.spec :as s]
6+
[cljs.spec.test :as stest]
7+
[cljs.test :refer-macros [deftest is]]
8+
[clojure.pprint :as pprint]))
9+
10+
(def sort-idempotent-prop
11+
(prop/for-all [v (gen/vector gen/int)]
12+
(= (sort v) (sort (sort v)))))
13+
14+
(tc/quick-check 100 sort-idempotent-prop)
15+
16+
;; Sample function and a function spec
17+
(defn fooo [i] (+ i 20))
18+
19+
(s/fdef fooo
20+
:args (s/cat :i integer?)
21+
:ret integer?
22+
:fn #(> (:ret %) (-> % :args :i)))
23+
24+
;; Utility functions to intergrate clojure.spec.test/check with clojure.test
25+
(defn summarize-results' [spec-check]
26+
(map (comp #(pprint/write % :stream nil) stest/abbrev-result) spec-check))
27+
28+
(defn check' [spec-check]
29+
(is (nil? (-> spec-check first :failure)) (summarize-results' spec-check)))
30+
31+
;; Tests
32+
(deftest fooish (check' (stest/check `fooo)))

0 commit comments

Comments
 (0)