This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-23
Channels
- # announcements (11)
- # architecture (14)
- # babashka (34)
- # bangalore-clj (8)
- # beginners (108)
- # calva (10)
- # cider (19)
- # circleci (9)
- # clj-kondo (19)
- # clojars (4)
- # clojure (62)
- # clojure-australia (2)
- # clojure-europe (62)
- # clojure-italy (14)
- # clojure-nl (8)
- # clojure-poland (1)
- # clojure-spec (14)
- # clojure-uk (59)
- # clojurescript (14)
- # community-development (5)
- # conjure (2)
- # core-async (10)
- # cryogen (1)
- # cursive (11)
- # data-science (1)
- # datahike (13)
- # datomic (21)
- # deps-new (4)
- # ethereum (1)
- # events (4)
- # fulcro (34)
- # helix (2)
- # jobs (2)
- # juxt (33)
- # kaocha (4)
- # lsp (18)
- # malli (4)
- # membrane (2)
- # off-topic (23)
- # re-frame (3)
- # reitit (4)
- # remote-jobs (1)
- # reveal (6)
- # shadow-cljs (47)
- # slack-help (2)
- # spacemacs (5)
- # sql (45)
- # startup-in-a-month (6)
- # testing (4)
- # tools-deps (21)
- # xtdb (4)
(defmacro before-each
[let-bindings & testing-blocks]
(assert (every? #(= 'testing (first %)) testing-blocks))
(let [bundles (for [block testing-blocks] `(let [~@let-bindings] ~block))]
`(do ~@bundles)))
the assert
isn't needed if you don't want to wrap every "block" in a testing
usage looks like this:
(deftest add-subtype-test
(before-each [sg {:subtypes []}]
(testing "accepts strings and keywords"
(is (add-subtype sg "type"))
(is (add-subtype sg :type)))
(testing "performs no change on keyword input"
(is (= "type" (first (:subtypes (add-subtype sg :type))))))
(testing "throws if given subtype isn't a keyword or string"
(is (thrown? java.lang.AssertionError (add-subtype sg nil))))))