fix spec for concat-vec & added tests
This commit is contained in:
parent
28b2381118
commit
6d520d3fa8
3 changed files with 29 additions and 8 deletions
|
@ -54,12 +54,7 @@
|
||||||
coll))
|
coll))
|
||||||
|
|
||||||
(defn-spec concat-vec vector?
|
(defn-spec concat-vec vector?
|
||||||
[& vs (s/* seq?)]
|
[& vs (s/* cp/string-sequence?)]
|
||||||
(into []
|
|
||||||
(apply concat vs)))
|
|
||||||
|
|
||||||
(defn-spec concat-str-vec cp/string-vector?
|
|
||||||
[& vs (s/* seq?)]
|
|
||||||
(into []
|
(into []
|
||||||
(apply concat vs)))
|
(apply concat vs)))
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@
|
||||||
(fqdn-string? (first split-string))
|
(fqdn-string? (first split-string))
|
||||||
(port-number? (edn/read-string (second split-string)))))))
|
(port-number? (edn/read-string (second split-string)))))))
|
||||||
|
|
||||||
(defn string-vector?
|
(defn string-sequence?
|
||||||
[input]
|
[input]
|
||||||
(and (vector? input)
|
(and (sequential? input)
|
||||||
(every? true?
|
(every? true?
|
||||||
(map #(string? %) input))))
|
(map #(string? %) input))))
|
||||||
|
|
||||||
|
|
26
src/test/cljc/dda/c4k_common/common_it_test.cljc
Normal file
26
src/test/cljc/dda/c4k_common/common_it_test.cljc
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
(ns dda.c4k-common.common-it-test
|
||||||
|
(:require
|
||||||
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||||
|
[clojure.spec.test.alpha :as st]
|
||||||
|
[dda.c4k-common.common :as cut]))
|
||||||
|
|
||||||
|
(st/instrument `cut/concat-vec)
|
||||||
|
|
||||||
|
(deftest should-concat-vec
|
||||||
|
(is (= ["a1" "a2" "b1"]
|
||||||
|
(cut/concat-vec ["a1" "a2"] ["b1"])))
|
||||||
|
(is (= ["a1" "a2" "b1"]
|
||||||
|
(cut/concat-vec '("a1" "a2") ["b1"])))
|
||||||
|
(is (= ["a1" "a2" "b1"]
|
||||||
|
(cut/concat-vec '("a1" "a2") '("b1")))))
|
||||||
|
|
||||||
|
(deftest should-refuse-illegal-inputs
|
||||||
|
(is (thrown? Exception
|
||||||
|
(cut/concat-vec ["a1" "a2"] "b1")))
|
||||||
|
(is (thrown? Exception
|
||||||
|
(cut/concat-vec ["a1" "a2"] nil)))
|
||||||
|
(is (thrown? Exception
|
||||||
|
(cut/concat-vec ["a1" "a2"] 2)))
|
||||||
|
(is (thrown? Exception
|
||||||
|
(cut/concat-vec {"a1" "a2"} []))))
|
Loading…
Reference in a new issue