#47 swap-states tests are in. composability tests ...next

This commit is contained in:
anatoly 2016-02-22 17:26:07 -05:00
parent b77bef3457
commit 977806626d
2 changed files with 27 additions and 1 deletions

View file

@ -12,4 +12,4 @@ test:
- boot test
- boot test-cljs
- boot test-cljs-advanced
- lein test2junit
- lein do clean, test2junit

View file

@ -88,3 +88,29 @@
(is (= "conn-sub" (dval conn)))
(is (= 42 (dval test-conn)))
(mount/stop)))))
#?(:clj
(deftest swap-states-with-states
(testing "swap-states should swap states with states and return all mount states if none is given"
(let [states (swap-states {#'tapp.nyse/conn #'mount.test.composable-fns/test-conn
#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})]
(is (= states (#'mount.core/find-all-states)))
(mount/start)
(is (map? (dval config)))
(is (vector? (dval nrepl)))
(is (= 42 (dval conn)))
(mount/stop)))
(testing "swap-states should swap states with states and return only states that it is given"
(let [t-states #{"#'is.not/here" #'mount.test.composable-fns/test-conn #'tapp.nyse/conn}
states (swap-states t-states {#'tapp.nyse/conn #'mount.test.composable-fns/test-conn
#'tapp.example/nrepl #'mount.test.composable-fns/test-nrepl})]
(is (= states t-states))
(apply mount/start states)
(is (instance? mount.core.NotStartedState (dval config)))
(is (instance? mount.core.NotStartedState (dval nrepl)))
(is (= 42 (dval conn)))
(is (= 42 (dval test-conn))) ;; test-conn is explicitly started via "t-states"
(mount/stop)))))