Skip to content

Instantly share code, notes, and snippets.

@augustl
Last active Nov 22, 2017
Embed
What would you like to do?
;; [org.clojure/clojure "1.8.0"]
;; [org.clojure/clojurescript "1.9.946"]
;; [org.clojure/core.async "0.3.465"]
(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]]))
;; Works fine
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (not (<! (expec/is-fulfilled db "my-expec-1"))))
(<! (expec/fulfill-expectation db "my-expec-1")))
(done)))))
;; Fails with:
;; ERROR in (expectations-basics) (Error:NaN:NaN)
;; expected: (<! (expec/is-fulfilled db "my-expec-1"))
;; actual: #object[Error Error: <! used not in (go ...) block]
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (not (<! (expec/is-fulfilled db "my-expec-1"))))
(<! (expec/fulfill-expectation db "my-expec-1"))
(is (<! (expec/is-fulfilled db "my-expec-1"))))
(done)))))
;; Also fails
(deftest expectations-basics
(testing "should work"
(async done
(go
(let [[db err] (<! (expec/create-memory-database))]
(<! (expec/add-expectation db {:key "my-expec-1"}))
(is (<! (expec/is-fulfilled db "my-expec-1"))))
(done)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment