-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
test.cljc
34 lines (29 loc) · 1.16 KB
/
test.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns taoensso.encore.test
{:deprecated "v3.31.0 (2022-10-27)"}
(:require
[clojure.test :as test]
[taoensso.encore :as enc :refer [have? if-cljs]]))
(enc/deprecated
#?(:clj
(defmacro expect
{:deprecated "v3.31.0 (2022-10-27)"
:doc "Prefer `clojure.test/is`, etc."}
([ expr] `(test/is ~expr))
([ val expr] `(test/is (= ~val ~expr)))
([bindings val expr] `(test/is (let ~bindings (= ~val ~expr))))))
(comment
(expect-let [foo {:a :A}] :A (:a foo))
(expect (thrown? Exception "foo")))
(defn- fixture-map->fn [{:keys [before after] :or {before 'do after 'do}}]
`(fn [f#] (~before) (f#) (~after)))
#?(:clj
(defmacro use-fixtures
{:deprecated "v3.31.0 (2022-10-27)"
:doc "Prefer `encore/test-fixtures`"}
[fixture-type & fixtures]
(have? [:el #{:each :once}] fixture-type)
(have? map? :in fixtures)
`(if-cljs
(test/use-fixtures ~fixture-type ~@fixtures)
(test/use-fixtures ~fixture-type ~@(map fixture-map->fn fixtures)))))
(comment (use-fixtures :each {:before (fn []) :after (fn [])})))