@@ -37,9 +37,12 @@ class LoginViewControllerTests: XCTestCase {
37
37
CelyWindowManager . manager. loginStyle = DummyStyles ( )
38
38
loginVC = CelyLoginViewController ( )
39
39
40
- loginVC. usernameField = UITextField ( )
40
+ let usernameTextField = UITextField ( )
41
+ let passwordTextField = UITextField ( )
42
+
43
+ loginVC. usernameField = usernameTextField
41
44
loginVC. usernameField? . tag = 0
42
- loginVC. passwordField = UITextField ( )
45
+ loginVC. passwordField = passwordTextField
43
46
loginVC. passwordField? . tag = 1
44
47
loginVC. textFields = [ loginVC. usernameField!, loginVC. passwordField!]
45
48
loginVC. viewDidLoad ( )
@@ -133,12 +136,12 @@ extension LoginViewControllerTests {
133
136
134
137
func testConvertNotification_Failure( ) {
135
138
let fakeUserInfo : [ AnyHashable : Any ] = [
136
- UIKeyboardAnimationDurationUserInfoKey : " FORCE FAIL " ,
137
- UIKeyboardFrameEndUserInfoKey : NSValue ( cgRect: . zero) ,
138
- UIKeyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
139
+ UIResponder . keyboardAnimationDurationUserInfoKey : " FORCE FAIL " ,
140
+ UIResponder . keyboardFrameEndUserInfoKey : NSValue ( cgRect: . zero) ,
141
+ UIWindow . keyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
139
142
]
140
143
141
- let fakeNotification = NSNotification ( name: . UIKeyboardWillChangeFrame , object: nil , userInfo: fakeUserInfo)
144
+ let fakeNotification = NSNotification ( name: UIResponder . keyboardWillChangeFrameNotification , object: nil , userInfo: fakeUserInfo)
142
145
143
146
let converted = loginVC. convertNotification ( notification: fakeNotification)
144
147
@@ -148,12 +151,12 @@ extension LoginViewControllerTests {
148
151
func testConvertNotification_Success( ) {
149
152
150
153
let fakeUserInfo : [ AnyHashable : Any ] = [
151
- UIKeyboardAnimationDurationUserInfoKey : NSNumber ( value: 20 ) ,
152
- UIKeyboardFrameEndUserInfoKey : NSValue ( cgRect: . zero) ,
153
- UIKeyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
154
+ UIResponder . keyboardAnimationDurationUserInfoKey : NSNumber ( value: 20 ) ,
155
+ UIResponder . keyboardFrameEndUserInfoKey : NSValue ( cgRect: . zero) ,
156
+ UIResponder . keyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
154
157
]
155
158
156
- let fakeNotification = NSNotification ( name: . UIKeyboardWillChangeFrame , object: nil , userInfo: fakeUserInfo)
159
+ let fakeNotification = NSNotification ( name: UIResponder . keyboardWillChangeFrameNotification , object: nil , userInfo: fakeUserInfo)
157
160
158
161
let converted = loginVC. convertNotification ( notification: fakeNotification)
159
162
@@ -163,8 +166,8 @@ extension LoginViewControllerTests {
163
166
XCTAssertEqual ( converted? . endFrame, . zero, " failed to set endFrame " )
164
167
XCTAssert ( type ( of: converted!. endFrame) == CGRect . self, " endFrame is not of type CGRect. " )
165
168
166
- XCTAssertEqual ( converted? . animationCurve, UIViewAnimationOptions ( rawValue: UInt ( 30 ) << 16 ) , " failed to set duration " )
167
- XCTAssert ( type ( of: converted!. animationCurve) == UIViewAnimationOptions . self, " animationCurve is not of type UIViewAnimationOptions. " )
169
+ XCTAssertEqual ( converted? . animationCurve, UIView . AnimationOptions ( rawValue: UInt ( 30 ) << 16 ) , " failed to set duration " )
170
+ XCTAssert ( type ( of: converted!. animationCurve) == UIView . AnimationOptions . self, " animationCurve is not of type UIViewAnimationOptions. " )
168
171
169
172
print ( converted ?? " failed to convert " )
170
173
}
@@ -176,12 +179,12 @@ extension LoginViewControllerTests {
176
179
loginVC. bottomLayoutConstraint. constant = 20
177
180
178
181
let fakeUserInfo : [ AnyHashable : Any ] = [
179
- UIKeyboardAnimationDurationUserInfoKey : NSNumber ( value: 20 ) ,
180
- UIKeyboardFrameEndUserInfoKey : NSValue ( cgRect: CGRect ( x: 0 , y: 200 , width: 320 , height: 500 ) ) ,
181
- UIKeyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
182
+ UIResponder . keyboardAnimationDurationUserInfoKey : NSNumber ( value: 20 ) ,
183
+ UIResponder . keyboardFrameEndUserInfoKey : NSValue ( cgRect: CGRect ( x: 0 , y: 200 , width: 320 , height: 500 ) ) ,
184
+ UIResponder . keyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
182
185
]
183
186
184
- let fakeNotification = NSNotification ( name: . UIKeyboardWillChangeFrame , object: nil , userInfo: fakeUserInfo)
187
+ let fakeNotification = NSNotification ( name: UIResponder . keyboardWillChangeFrameNotification , object: nil , userInfo: fakeUserInfo)
185
188
186
189
loginVC. keyboardNotification ( notification: fakeNotification)
187
190
@@ -198,12 +201,12 @@ extension LoginViewControllerTests {
198
201
loginVC. bottomLayoutConstraint. constant = 20
199
202
200
203
let fakeUserInfo : [ AnyHashable : Any ] = [
201
- UIKeyboardAnimationDurationUserInfoKey : " FORCE FAIL " ,
202
- UIKeyboardFrameEndUserInfoKey : NSValue ( cgRect: CGRect ( x: 0 , y: 200 , width: 320 , height: 500 ) ) ,
203
- UIKeyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
204
+ UIResponder . keyboardAnimationDurationUserInfoKey : " FORCE FAIL " ,
205
+ UIResponder . keyboardFrameEndUserInfoKey : NSValue ( cgRect: CGRect ( x: 0 , y: 200 , width: 320 , height: 500 ) ) ,
206
+ UIResponder . keyboardAnimationCurveUserInfoKey : NSNumber ( value: 30 )
204
207
]
205
208
206
- let fakeNotification = NSNotification ( name: . UIKeyboardWillChangeFrame , object: nil , userInfo: fakeUserInfo)
209
+ let fakeNotification = NSNotification ( name: UIResponder . keyboardWillChangeFrameNotification , object: nil , userInfo: fakeUserInfo)
207
210
208
211
loginVC. keyboardNotification ( notification: fakeNotification)
209
212
0 commit comments