Skip to content

Instantly share code, notes, and snippets.

@augustl
Created November 27, 2017 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save augustl/4db5ec87bfe60199a9c91b950dc20657 to your computer and use it in GitHub Desktop.
Save augustl/4db5ec87bfe60199a9c91b950dc20657 to your computer and use it in GitHub Desktop.
(ns huffda.expectations-basics-test
(:require [clojure.test :refer [deftest testing is async]]
[huffda.expectations :as expec]
[cljs.core.async :refer [chan <! >! put! close! alts! timeout promise-chan]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
(defmacro async-test [& form]
`(async done
(go
(do ~@form)
(done))))
(deftest expectations-basics
(testing "should work"
(async-test
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"} 123))
(is (do (not (<! (expec/is-fulfilled db "my-expec-1")))))
(<! (expec/fulfill-expectation db "my-expec-1" true))
(is (do (<! (expec/is-fulfilled db "my-expec-1"))))))))
;; #object[Error Error: <! used not in (go ...) block]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment