Skip to content

Commit

Permalink
Adapt test for unid with map arg as well
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan committed May 29, 2024
1 parent b1ab5ce commit a9e08e0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/swark/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@
(t/deftest unid
(t/is (string? (sut/unid)))
(t/is (-> #{"x"} sut/unid count #{1}))
(t/is (-> {"x" :val-of-x} sut/unid count #{1})) ;; Works with maps as well
(t/is (->> #{"xyzab"} (sut/unid {:min-length 5}) count (>= 5)))
(t/is (->> {"xyzab" :val-of-xyzab} (sut/unid {:min-length 5}) count (>= 5)))
(t/is (-> (reduce (fn [x _] (conj x (sut/unid x))) #{} (range 999)) count #{999}))
(t/is (-> (reduce (fn [x _] (assoc x (sut/unid x) :another-val)) {} (range 999)) count #{999}))
(t/is (-> (reduce (fn [x _] (conj x (sut/unid {:min-length 4} x))) #{} (range 999)) count #{999}))
(t/is (-> (reduce (fn [x _] (assoc x (sut/unid {:min-length 4} x) :another-val)) {} (range 999)) count #{999}))
(let [three-digits (sut/unid {:min-length 3 :no-dashes? true :filter-regex #"\d"} #{})
four-letters (sut/unid {:min-length 4 :no-dashes? true :filter-regex #"\D"} #{})
five-chars (sut/unid {:min-length 5} #{})]
Expand Down

0 comments on commit a9e08e0

Please sign in to comment.