@@ -260,6 +260,54 @@ struct VAPIDConfigurationTests {
260260 """
261261 )
262262 }
263+
264+ @Test func decodesIncompleteConfiguration( ) throws {
265+ #expect(
266+ try JSONDecoder ( ) . decode ( VAPID . Configuration. self, from: Data (
267+ """
268+ {
269+ " contactInformation " : " mailto:[email protected] " , 270+ " expirationDuration " : 79200,
271+ " primaryKey " : " FniTgSrf0l+BdfeC6LiblKXBbY4LQm0S+4STNCoJI+0= " ,
272+ " validityDuration " : 72000
273+ }
274+ """ . utf8
275+ ) ) ==
276+ VAPID . Configuration (
277+ key: key1,
278+ contactInformation
: . email
( " [email protected] " ) 279+ )
280+ )
281+ }
282+
283+ @Test func decodesWholeConfiguration( ) throws {
284+ #expect(
285+ try JSONDecoder ( ) . decode ( VAPID . Configuration. self, from: Data (
286+ """
287+ {
288+ " contactInformation " : " mailto:[email protected] " , 289+ " deprecatedKeys " : [
290+ " bcZgo/p2WFqXaKFzmYaDKO/gARjWvGi3oXyHM2QNlfE= "
291+ ],
292+ " expirationDuration " : 3600,
293+ " keys " : [
294+ " wyQaGWNwvXKzVmPIhkqVQvQ+FKx1SNqHJ+re8n2ORrk= "
295+ ],
296+ " primaryKey " : " FniTgSrf0l+BdfeC6LiblKXBbY4LQm0S+4STNCoJI+0= " ,
297+ " validityDuration " : 36000
298+ }
299+ """ . utf8
300+ ) ) ==
301+ VAPID . Configuration (
302+ primaryKey: key1,
303+ keys: [ key2] ,
304+ deprecatedKeys: [ key1, key2, key3] ,
305+ contactInformation
: . email
( " [email protected] " ) , 306+ expirationDuration: . hours( 1 ) ,
307+ validityDuration: . hours( 10 )
308+ )
309+ )
310+ }
263311 }
264312
265313 @Suite
@@ -303,6 +351,11 @@ struct VAPIDConfigurationTests {
303351 #expect( VAPID . Configuration. Duration. seconds ( 175 ) > VAPID . Configuration. Duration. minutes ( 2 ) )
304352 }
305353
354+ @Test func addingToDates( ) {
355+ let now = Date ( )
356+ #expect( now. adding ( . seconds( 5 ) ) == now. addingTimeInterval ( 5 ) )
357+ }
358+
306359 @Test func coding( ) throws {
307360 #expect( String ( decoding: try JSONEncoder ( ) . encode ( VAPID . Configuration. Duration ( 60 ) ) , as: UTF8 . self) == " 60 " )
308361
0 commit comments