Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(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#)))))
@samedhi
Copy link
Author

samedhi commented Jan 17, 2020

[: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 |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment