Skip to content

Commit

Permalink
[#37] Add test for nil map
Browse files Browse the repository at this point in the history
  • Loading branch information
barracudarin authored and tolitius committed May 11, 2020
1 parent b91250b commit f860f0a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/cprop/test/tools.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
(deftest contains-in?
(let [config {:a {:b {:c [{:d 1} 2]}}}]
(testing "true conditions"
(doseq [path [nil [] [:a] [:a :b :c] [:a :b :c 1] [:a :b :c 0 :d]]]
(is (true? (sut/contains-in? config path)) path)
(is (not= :missing (get-in config path :missing)))))
(testing "nil map edge-case"
(is (true? (sut/contains-in? nil [])))
(is (not= :missing (get-in nil [] :missing)))
(is (true? (sut/contains-in? nil nil)))
(is (not= :missing (get-in nil nil :missing))))
(testing "primary use-cases"
(doseq [path [nil [] [:a] [:a :b :c] [:a :b :c 1] [:a :b :c 0 :d]]]
(is (true? (sut/contains-in? config path)) path)
(is (not= :missing (get-in config path :missing))))))
(testing "false conditions"
(testing "nil map edge-case"
(is (false? (sut/contains-in? nil [:a])) "nil path")
(is (= :missing (get-in nil [:a] :missing))))
(doseq [path [[nil] [:a :e] [:a :b :c 69]]]
(is (false? (sut/contains-in? config path)) path)
(is (= :missing (get-in config path :missing)))))))

0 comments on commit f860f0a

Please sign in to comment.