Convert sync tests to midje
This commit is contained in:
parent
07e85a4d30
commit
421a921fd4
2 changed files with 9 additions and 10 deletions
|
@ -1,6 +1,5 @@
|
|||
(ns grub.test.unit.state
|
||||
(:require [grub.state :as state]
|
||||
[clojure.test :refer :all]
|
||||
[midje.sweet :refer :all]
|
||||
[hasch.core :as hasch]
|
||||
[clojure.core.async :as a :refer [<!! >!! chan go]]))
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
(ns grub.test.unit.sync
|
||||
(:require [grub.sync :as s]
|
||||
[clojure.test :refer :all]
|
||||
[midje.sweet :refer :all]
|
||||
[hasch.core :as hasch]))
|
||||
|
||||
(deftest initial-state
|
||||
(fact "Sets correct initial state"
|
||||
(let [grubs [{:id "1" :text "2 bananas" :completed false}
|
||||
{:id "2" :text "3 onions" :completed false}]
|
||||
recipes []
|
||||
|
@ -11,17 +11,17 @@
|
|||
"2" {:id "2" :text "3 onions" :completed false}}
|
||||
:recipes {}}
|
||||
expected-hash (hasch/uuid expected-state)]
|
||||
(is (= [{:state expected-state :hash expected-hash}] (s/initial-state grubs recipes)))))
|
||||
(s/initial-state grubs recipes) => [{:state expected-state :hash expected-hash}]))
|
||||
|
||||
(deftest get-current-state-returns-last-state
|
||||
(fact "Get current state returns last state"
|
||||
(let [states [{:hash "asdf" :state {:a :b}}
|
||||
{:hash "fdsa" :state {:c :d}}]]
|
||||
(is (= {:c :d} (s/get-current-state states)))))
|
||||
(s/get-current-state states) => {:c :d}))
|
||||
|
||||
(deftest get-history-state-returns-state-with-hash
|
||||
(fact "Get history state returns state with given hash"
|
||||
(let [states [{:hash "hash1" :state {:a :b}}
|
||||
{:hash "hash2" :state {:c :d}}
|
||||
{:hash "hash3" :state {:e :f}}]]
|
||||
(is (= {:a :b} (s/get-history-state states "hash1")))
|
||||
(is (= {:c :d} (s/get-history-state states "hash2")))
|
||||
(is (= {:e :f} (s/get-history-state states "hash3")))))
|
||||
(s/get-history-state states "hash1") => {:a :b}
|
||||
(s/get-history-state states "hash2") => {:c :d}
|
||||
(s/get-history-state states "hash3") => {:e :f}))
|
||||
|
|
Loading…
Reference in a new issue