Last active
November 22, 2017 21:27
-
-
Save augustl/4a679dc95847db4434d0e7348651224f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; [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