Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- added some tests

  • Loading branch information...
commit 3f8d4602ccb56529a387e320ffaff352345cfc90 1 parent 1d591e1
@niclasmeier niclasmeier authored
View
4 src/herolabs/apns/message.clj
@@ -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)
)
)
View
20 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"}}})
+ )
+
Please sign in to comment.
Something went wrong with that request. Please try again.