Simple tests for [un]completing, deleting grubs

This commit is contained in:
Nicholas Kariniemi 2013-08-17 14:49:41 +03:00
parent 9943a58fd7
commit 44798d5b4b

View file

@ -9,10 +9,31 @@
(with-state-changes [(before :facts (do (db/connect-and-handle-events test-db)
(mc/drop db/grub-collection)))]
(fact
"Add grub"
"Create grub"
(fact "sending an event creates a grub"
(let [test-grub "testgrub"
test-id 12345]
(>!! @db/incoming-events {:event :create :_id test-id :grub test-grub})
(mc/find-one-as-map db/grub-collection {:_id test-id}) =>
{:_id test-id :grub test-grub :completed false}))))
{:_id test-id :grub test-grub :completed false})))
(fact "Complete grub"
(fact "sending an event completes a grub"
(let [test-grub {:_id 123456 :completed false}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :complete :_id (:_id test-grub)})
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)}) =>
{:_id (:_id test-grub) :completed true})))
(fact "Uncomplete grub"
(fact "sending an event uncompletes a grub"
(let [test-grub {:_id 123456 :completed true}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :uncomplete :_id (:_id test-grub)})
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)}) =>
{:_id (:_id test-grub) :completed false})))
(fact "Delete grub"
(fact "sending an event deletes a grub"
(let [test-grub {:_id 123456 :completed true}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :delete :_id (:_id test-grub)})
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)}) =>
nil))))