Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- added some tests
  • Loading branch information
niclasmeier committed Mar 28, 2012
1 parent 1d591e1 commit 3f8d460
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/herolabs/apns/message.clj
Expand Up @@ -5,8 +5,8 @@

(defn with-sound [message sound]
(cond
(= :default sound) (update-in message [:apns ] #(dissoc % :sound ))
(= "default" sound) (update-in message [:apns ] #(dissoc % :sound ))
(= :default sound) (update-in message [:aps ] #(dissoc % :sound ))
(= "default" sound) (update-in message [:aps ] #(dissoc % :sound ))
:else (assoc-in message [:aps :sound ] sound)
)
)
Expand Down
20 changes: 20 additions & 0 deletions test/herolabs_test/apns/message.clj
@@ -0,0 +1,20 @@
(ns herolabs-test.apns
(:use midje.sweet
herolabs.apns.message
))



(facts "about message assembly"
(with-badge {} 1) => (just {:aps {:badge 1}})
(with-sound {} :default) => (just {:aps nil})
(with-sound {} "default") => (just {:aps nil})
(with-sound {} :chimes) => (just {:aps {:sound :chimes}})
(with-standard-alert {} "Hello world") => (just {:aps {:alert "Hello world"}})
(with-action-loc-key {} "TEST") => (just {:aps {:alert {:action-loc-key "TEST"}}})
(with-loc-key {} "TEST") => (just {:aps {:alert {:loc-key "TEST"}}})
(with-loc-args {} "foo") => (just {:aps (just {:alert (just {:loc-args (just ["foo"])})})})
(with-loc-args {} ["foo" "bar"]) => (just {:aps (just {:alert (just {:loc-args (just ["foo" "bar"])})})})
(with-alert-body {} "TEST") => (just {:aps {:alert {:body "TEST"}}})
)

0 comments on commit 3f8d460

Please sign in to comment.