@@ -111,10 +111,40 @@ class ParsePushPayloadAnyTests: XCTestCase {
111
111
let encoded2 = try ParseCoding . parseEncoder ( ) . encode ( fcmPayload)
112
112
let decoded2 = try ParseCoding . jsonDecoder ( ) . decode ( ParsePushPayloadFirebase . self, from: encoded2)
113
113
XCTAssertEqual ( fcmPayload, decoded2)
114
- XCTAssertEqual ( fcmPayload. description,
115
- " ParsePushPayloadable ({ \" collapseKey \" : \" nope \" , \" data \" :{ \" help \" : \" you \" }, \" delayWhileIdle \" :false, \" dryRun \" :false, \" notification \" :{ \" android_channel_id \" : \" you \" , \" badge \" : \" no \" , \" body \" : \" android \" , \" body_loc-key \" : \" cousin \" , \" body-loc-args \" :[ \" mother \" ], \" click_action \" : \" to \" , \" color \" : \" blue \" , \" icon \" : \" world \" , \" image \" : \" icon \" , \" sound \" : \" yes \" , \" subtitle \" : \" trip \" , \" tag \" : \" it \" , \" title \" : \" hello \" , \" title_loc_args \" :[ \" arg \" ], \" title_loc_key \" : \" it \" }, \" restrictedPackageName \" : \" geez \" , \" title \" : \" peace \" , \" uri \" : \" https: \\ / \\ /parse.org \" }) " )
116
114
let decodedAny2 = try ParseCoding . jsonDecoder ( ) . decode ( ParsePushPayloadAny . self, from: encoded) . convertToApple ( )
117
115
XCTAssertEqual ( decodedAny2, applePayload)
116
+ #if !os(Linux) && !os(Android) && !os(Windows)
117
+ XCTAssertEqual ( fcmPayload. description,
118
+ " ParsePushPayloadable ({ \" collapseKey \" : \" nope \" , \" data \" :{ \" help \" : \" you \" }, \" delayWhileIdle \" :false, \" dryRun \" :false, \" notification \" :{ \" android_channel_id \" : \" you \" , \" badge \" : \" no \" , \" body \" : \" android \" , \" body_loc-key \" : \" cousin \" , \" body-loc-args \" :[ \" mother \" ], \" click_action \" : \" to \" , \" color \" : \" blue \" , \" icon \" : \" world \" , \" image \" : \" icon \" , \" sound \" : \" yes \" , \" subtitle \" : \" trip \" , \" tag \" : \" it \" , \" title \" : \" hello \" , \" title_loc_args \" :[ \" arg \" ], \" title_loc_key \" : \" it \" }, \" restrictedPackageName \" : \" geez \" , \" title \" : \" peace \" , \" uri \" : \" https: \\ / \\ /parse.org \" }) " )
119
+ #endif
120
+ }
121
+
122
+ func testAppleAlertStringDecode( ) throws {
123
+ let sound = ParsePushAppleSound ( critical: true , name: " hello " , volume: 7 )
124
+ let alert = ParsePushAppleAlert ( body: " pull up " )
125
+ var anyPayload = ParsePushPayloadAny ( )
126
+ anyPayload. alert = alert
127
+ anyPayload. badge = AnyCodable ( 1 )
128
+ anyPayload. sound = AnyCodable ( sound)
129
+ anyPayload. urlArgs = [ " help " ]
130
+ anyPayload. interruptionLevel = " yolo "
131
+ anyPayload. topic = " naw "
132
+ anyPayload. threadId = " yep "
133
+ anyPayload. collapseId = " nope "
134
+ anyPayload. pushType = . background
135
+ anyPayload. targetContentId = " press "
136
+ anyPayload. relevanceScore = 2.0
137
+ anyPayload. priority = 6
138
+ anyPayload. contentAvailable = 1
139
+ anyPayload. mutableContent = 1
140
+
141
+ let applePayload = anyPayload. convertToApple ( )
142
+ guard let jsonData = " { \" alert \" : \" pull up \" , \" badge \" :1, \" collapse_id \" : \" nope \" , \" content-available \" :1, \" interruptionLevel \" : \" yolo \" , \" mutable-content \" :1, \" priority \" :6, \" push_type \" : \" background \" , \" relevance-score \" :2, \" sound \" :{ \" critical \" :true, \" name \" : \" hello \" , \" volume \" :7}, \" targetContentIdentifier \" : \" press \" , \" threadId \" : \" yep \" , \" topic \" : \" naw \" , \" urlArgs \" :[ \" help \" ]} " . data ( using: . utf8) else {
143
+ XCTFail ( " Should have unwrapped " )
144
+ return
145
+ }
146
+ let decodedAlert = try ParseCoding . jsonDecoder ( ) . decode ( ParsePushPayloadAny . self, from: jsonData) . convertToApple ( )
147
+ XCTAssertEqual ( decodedAlert, applePayload)
118
148
}
119
149
120
150
func testConvertToApple( ) throws {
@@ -196,9 +226,11 @@ class ParsePushPayloadAnyTests: XCTestCase {
196
226
let encoded = try ParseCoding . parseEncoder ( ) . encode ( fcmPayload)
197
227
let decoded = try ParseCoding . jsonDecoder ( ) . decode ( ParsePushPayloadFirebase . self, from: encoded)
198
228
XCTAssertEqual ( fcmPayload, decoded)
199
- XCTAssertEqual ( fcmPayload. description,
200
- " ParsePushPayloadable ({ \" collapseKey \" : \" nope \" , \" contentAvailable \" :true, \" data \" :{ \" help \" : \" you \" }, \" delayWhileIdle \" :false, \" dryRun \" :false, \" mutableContent \" :true, \" notification \" :{ \" android_channel_id \" : \" you \" , \" badge \" : \" no \" , \" body \" : \" android \" , \" body_loc-key \" : \" cousin \" , \" body-loc-args \" :[ \" mother \" ], \" click_action \" : \" to \" , \" color \" : \" blue \" , \" icon \" : \" world \" , \" image \" : \" icon \" , \" sound \" : \" yes \" , \" subtitle \" : \" trip \" , \" tag \" : \" it \" , \" title \" : \" hello \" , \" title_loc_args \" :[ \" arg \" ], \" title_loc_key \" : \" it \" }, \" priority \" : \" high \" , \" restrictedPackageName \" : \" geez \" , \" title \" : \" peace \" , \" uri \" : \" https: \\ / \\ /parse.org \" }) " )
201
229
let decoded2 = try ParseCoding . jsonDecoder ( ) . decode ( ParsePushPayloadAny . self, from: encoded) . convertToFirebase ( )
202
230
XCTAssertEqual ( decoded2, fcmPayload)
231
+ #if !os(Linux) && !os(Android) && !os(Windows)
232
+ XCTAssertEqual ( fcmPayload. description,
233
+ " ParsePushPayloadable ({ \" collapseKey \" : \" nope \" , \" contentAvailable \" :true, \" data \" :{ \" help \" : \" you \" }, \" delayWhileIdle \" :false, \" dryRun \" :false, \" mutableContent \" :true, \" notification \" :{ \" android_channel_id \" : \" you \" , \" badge \" : \" no \" , \" body \" : \" android \" , \" body_loc-key \" : \" cousin \" , \" body-loc-args \" :[ \" mother \" ], \" click_action \" : \" to \" , \" color \" : \" blue \" , \" icon \" : \" world \" , \" image \" : \" icon \" , \" sound \" : \" yes \" , \" subtitle \" : \" trip \" , \" tag \" : \" it \" , \" title \" : \" hello \" , \" title_loc_args \" :[ \" arg \" ], \" title_loc_key \" : \" it \" }, \" priority \" : \" high \" , \" restrictedPackageName \" : \" geez \" , \" title \" : \" peace \" , \" uri \" : \" https: \\ / \\ /parse.org \" }) " )
234
+ #endif
203
235
}
204
236
}
0 commit comments