Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit f69e747

Browse files
mariuscDominik Hadl
authored andcommitted
Fixed so that tests would pass
1 parent 523dce2 commit f69e747

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

KeyboardHelper/Classes/KeyboardAppearanceInfo.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct KeyboardAppearanceInfo {
3535
Return a `CGRect` or `CGRectZero`.
3636
*/
3737
public var endFrame: CGRect {
38-
return (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue ?? .zero
38+
return (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? .zero
3939
}
4040

4141
/**
@@ -45,7 +45,7 @@ public struct KeyboardAppearanceInfo {
4545
*/
4646
public var belongsToCurrentApp: Bool {
4747
if #available(iOS 9.0, *) {
48-
return (userInfo[UIKeyboardIsLocalUserInfoKey] as? NSString)?.boolValue ?? true
48+
return (userInfo[UIKeyboardIsLocalUserInfoKey] as? Bool) ?? true
4949
} else {
5050
return true
5151
}
@@ -56,7 +56,7 @@ public struct KeyboardAppearanceInfo {
5656
By default: `0.25`.
5757
*/
5858
public var animationDuration: Double {
59-
return (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSString)?.doubleValue ?? 0.25
59+
return (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.25
6060
}
6161

6262
/**

KeyboardHelperTests/Tests/KeyboardAppearanceInfoTests.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import KeyboardHelper
1111

1212
class KeyboardAppearanceInfoTests: XCTestCase {
1313

14-
var apperanceInfo: KeyboardAppearanceInfo!
14+
var appearanceInfo: KeyboardAppearanceInfo!
1515
var defaultsAppearanceInfo : KeyboardAppearanceInfo!
1616

1717
override func setUp() {
@@ -33,42 +33,43 @@ class KeyboardAppearanceInfoTests: XCTestCase {
3333

3434
// Fake the notification
3535
let note = Notification(name: NSNotification.Name.UIKeyboardWillShow, object: nil, userInfo: testUserInfo)
36-
apperanceInfo = KeyboardAppearanceInfo(notification: note)
36+
appearanceInfo = KeyboardAppearanceInfo(notification: note)
3737
let defaultNote = Notification(name: NSNotification.Name.UIKeyboardWillShow, object: nil, userInfo: nil)
3838
defaultsAppearanceInfo = KeyboardAppearanceInfo(notification: defaultNote)
3939
}
4040

4141
func testBeginFrame() {
42-
XCTAssertEqual(apperanceInfo.beginFrame, CGRect(x: 100, y: 100, width: 100, height: 100),
42+
XCTAssertEqual(appearanceInfo.beginFrame, CGRect(x: 100, y: 100, width: 100, height: 100),
4343
"Parsing beginFrame from keyboard appearance info failed.")
4444
XCTAssertEqual(defaultsAppearanceInfo.beginFrame, CGRect.zero,
4545
"Parsing default beginFrame from keyboard appearance info failed.")
4646
}
4747

4848
func testEndFrame() {
49-
XCTAssertEqual(apperanceInfo.endFrame, CGRect(x: 200, y: 200, width: 200, height: 200),
49+
XCTAssertEqual(appearanceInfo.endFrame, CGRect(x: 200, y: 200, width: 200, height: 200),
5050
"Parsing endFrame from keyboard appearance info failed.")
5151
XCTAssertEqual(defaultsAppearanceInfo.endFrame, CGRect.zero,
5252
"Parsing default endFrame from keyboard appearance info failed.")
5353
}
5454

5555
@available(iOS 9.0, *)
5656
func testBelongsToCurrentApp() {
57-
XCTAssertEqual(apperanceInfo.belongsToCurrentApp, false,
57+
XCTAssertEqual(appearanceInfo.belongsToCurrentApp, false,
5858
"Parsing belongsToCurrentApp from keyboard appearance info failed.")
5959
XCTAssertEqual(defaultsAppearanceInfo.belongsToCurrentApp, true,
6060
"Parsing default belongsToCurrentApp from keyboard appearance info failed.")
6161
}
6262

6363
func testAnimationDuration() {
64-
XCTAssertEqual(apperanceInfo.animationDuration, Double(3),
64+
65+
XCTAssertEqual(appearanceInfo.animationDuration, Double(3),
6566
"Parsing animationDuration from keyboard appearance info failed.")
6667
XCTAssertEqual(defaultsAppearanceInfo.animationDuration, Double(0.25),
6768
"Parsing default animationDuration from keyboard appearance info failed.")
6869
}
6970

7071
func testAnimationCurve() {
71-
XCTAssertEqual(apperanceInfo.animationCurve, UIViewAnimationCurve(rawValue: 2),
72+
XCTAssertEqual(appearanceInfo.animationCurve, UIViewAnimationCurve(rawValue: 2),
7273
"Parsing animationCurve from keyboard appearance info failed.")
7374
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve(rawValue: defaultsAppearanceInfo.animationCurve.rawValue),
7475
"Parsing default animationCurve from keyboard appearance info failed.")
@@ -77,7 +78,7 @@ class KeyboardAppearanceInfoTests: XCTestCase {
7778
func testAnimateAlong() {
7879
let expectation = self.expectation(description: "Animate along should take 3 seconds")
7980

80-
apperanceInfo.animateAlong({ () -> Void in
81+
appearanceInfo.animateAlong({ () -> Void in
8182
// Do animations
8283
}) { (finished) -> Void in
8384
if finished {

0 commit comments

Comments
 (0)