@@ -9,17 +9,32 @@ import XCTest
9
9
class LocalStorageTests : XCTestCase {
10
10
override func setUp( ) {
11
11
super. setUp ( )
12
+
12
13
LocalStorageTests . clearTestUserDefaults ( )
14
+ LocalStorageTests . clearTestKeychain ( )
13
15
}
14
16
15
- static let userDefaultsSuiteName = " localstorage.tests "
17
+ static let localStorageTestSuiteName = " localstorage.tests "
16
18
17
19
private static func getTestUserDefaults( ) -> UserDefaults {
18
- UserDefaults ( suiteName: userDefaultsSuiteName ) !
20
+ UserDefaults ( suiteName: localStorageTestSuiteName ) !
19
21
}
20
22
21
23
private static func clearTestUserDefaults( ) {
22
- getTestUserDefaults ( ) . removePersistentDomain ( forName: userDefaultsSuiteName)
24
+ getTestUserDefaults ( ) . removePersistentDomain ( forName: localStorageTestSuiteName)
25
+ }
26
+
27
+ private static func getTestKeychain( ) -> IterableKeychain {
28
+ IterableKeychain ( wrapper: KeychainWrapper ( serviceName: localStorageTestSuiteName) )
29
+ }
30
+
31
+ private static func clearTestKeychain( ) {
32
+ let testKeychain = getTestKeychain ( )
33
+
34
+ testKeychain. email = nil
35
+ testKeychain. userId = nil
36
+ testKeychain. authToken = nil
37
+ testKeychain. setLastPushPayload ( nil , withExpiration: nil )
23
38
}
24
39
25
40
func testUserIdAndEmail( ) throws {
@@ -96,7 +111,8 @@ class LocalStorageTests: XCTestCase {
96
111
97
112
func testPayload( ) throws {
98
113
let mockDateProvider = MockDateProvider ( )
99
- let localStorage = LocalStorage ( userDefaults: LocalStorageTests . getTestUserDefaults ( ) )
114
+ let localStorage = LocalStorage ( userDefaults: LocalStorageTests . getTestUserDefaults ( ) , keychain: LocalStorageTests . getTestKeychain ( ) )
115
+
100
116
let payload : [ AnyHashable : Any ] = [
101
117
102
118
" device " : [
0 commit comments