@@ -114,16 +114,21 @@ class LocalStorageTests: XCTestCase {
114
114
] ,
115
115
] ,
116
116
]
117
+
117
118
let currentDate = Date ( )
118
119
let expiration = Calendar . current. date ( byAdding: Calendar . Component. hour, value: 24 , to: currentDate) !
119
- localStorage. save ( payload: payload, withExpiration: expiration)
120
+
121
+ localStorage. saveLastPushPayload ( payload, withExpiration: expiration)
122
+
120
123
// 23 hours, not expired, still present
121
124
mockDateProvider. currentDate = Calendar . current. date ( byAdding: Calendar . Component. hour, value: 23 , to: currentDate) !
122
- let fromLocalStorage : [ AnyHashable : Any ] = localStorage. getPayload ( currentDate: mockDateProvider. currentDate) !
125
+ let fromLocalStorage : [ AnyHashable : Any ] = localStorage. getLastPushPayload ( mockDateProvider. currentDate) !
126
+
123
127
XCTAssertTrue ( NSDictionary ( dictionary: payload) . isEqual ( to: fromLocalStorage) )
124
128
125
129
mockDateProvider. currentDate = Calendar . current. date ( byAdding: Calendar . Component. hour, value: 25 , to: currentDate) !
126
- let fromLocalStorage2 : [ AnyHashable : Any ] ? = localStorage. getPayload ( currentDate: mockDateProvider. currentDate)
130
+ let fromLocalStorage2 : [ AnyHashable : Any ] ? = localStorage. getLastPushPayload ( mockDateProvider. currentDate)
131
+
127
132
XCTAssertNil ( fromLocalStorage2)
128
133
}
129
134
@@ -150,13 +155,16 @@ class LocalStorageTests: XCTestCase {
150
155
] ,
151
156
" someClass " : A ( ) ,
152
157
]
158
+
153
159
let currentDate = Date ( )
154
160
let expiration = Calendar . current. date ( byAdding: Calendar . Component. hour, value: 24 , to: currentDate) !
155
- localStorage. save ( payload: payload, withExpiration: expiration)
161
+
162
+ localStorage. saveLastPushPayload ( payload, withExpiration: expiration)
156
163
157
164
// 23 hours, not expired, still present
158
165
mockDateProvider. currentDate = Calendar . current. date ( byAdding: Calendar . Component. hour, value: 23 , to: currentDate) !
159
- let fromLocalStorage = localStorage. getPayload ( currentDate: mockDateProvider. currentDate)
166
+ let fromLocalStorage = localStorage. getLastPushPayload ( mockDateProvider. currentDate)
167
+
160
168
XCTAssertNil ( fromLocalStorage)
161
169
}
162
170
0 commit comments