-
-
Save samedhi/f8c6aa8eb5ca435ffac808da27e85978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns firemore-functions.test-macros | |
(:require | |
[cljs.test :as t] | |
["firebase-admin" :as admin] | |
;; [firemore-functions.test-setup :as test-setup] | |
[promesa.core :as promesa])) | |
(defmacro deftest-function [symbol-name fx fixtures & body] | |
`(t/deftest ~symbol-name | |
(t/async | |
done# | |
(let [wrapped# (firemore-functions.test-setup/wrap ~fx) | |
setup# (promesa.core/all | |
(for [[sym# path# doc#] ~fixtures] | |
(.. admin | |
(firestore) | |
(doc path#) | |
(set (cljs.core/clj->js (firemore-functions.test-setup/snapshot doc# path#)))))) | |
execute# (fn [[doc#]] | |
(wrapped# doc#)) | |
observe# (fn [] (promesa.core/all | |
(for [path# ~(mapv second fixtures)] | |
(.. admin (firestore) (doc path#) (get))))) | |
confirm# (fn [~@(map first fixtures)] | |
~@body) | |
cleanup# (fn [] (done#)) | |
] | |
(promesa.core/chain | |
setup# | |
execute# | |
observe# | |
confirm# | |
cleanup#))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[:test] Build completed. (59 files, 2 compiled, 2 warnings, 0.40s)
------ WARNING #1 - :undeclared-ns ---------------------------------------------
File: /Users/stephen/firemore-functions/test/firemore_functions/core_test.cljs:35:1
32 | confirm
33 | cleanup))))
34 |
35 | (deftest-function create-example-with-macro-test
-------^------------------------------------------------------------------------
No such namespace: firemore-functions.test-macros, could not locate firemore_functions/test_macros.cljs, firemore_functions/test_macros.cljc, or JavaScript source providing "firemore-functions.test-macros" (Please check that namespaces with dashes use underscores in the ClojureScript file name)
36 | sut/create-example-cloudfx
37 | [])
38 |
------ WARNING #2 - :undeclared-var --------------------------------------------
File: /Users/stephen/firemore-functions/test/firemore_functions/core_test.cljs:35:1
32 | confirm
33 | cleanup))))
34 |
35 | (deftest-function create-example-with-macro-test
-------^------------------------------------------------------------------------
Use of undeclared Var firemore-functions.test-macros/admin
36 | sut/create-example-cloudfx
37 | [])
38 |