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

Commit f42dea7

Browse files
author
Timmi Trinks
committed
tests for default notification with error messages
1 parent 87914c8 commit f42dea7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

KeyboardHelperTests/Tests/KeyboardAppearanceInfoTests.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,53 @@ class KeyboardAppearanceInfoTests: XCTestCase {
2525
UIKeyboardAnimationCurveUserInfoKey: UIViewAnimationCurve.EaseOut.rawValue,
2626
]
2727

28-
var defaultParsingUserInfo: [String: AnyObject] = [
29-
UIKeyboardFrameBeginUserInfoKey: "bla",
30-
UIKeyboardFrameEndUserInfoKey: "bla",
31-
UIKeyboardAnimationDurationUserInfoKey: NSValue(CGRect: CGRect(x: 100, y: 100, width: 100, height: 100)),
32-
UIKeyboardAnimationCurveUserInfoKey: "bla",
33-
]
34-
3528
if #available(iOS 9.0, *) {
3629
testUserInfo[UIKeyboardIsLocalUserInfoKey] = false
37-
defaultParsingUserInfo[UIKeyboardIsLocalUserInfoKey] = "this shouldn't work"
3830
} else {
3931
print("UIKeyboardIsLocalUserInfoKey is not available before iOS9.")
4032
}
4133

4234
// Fake the notification
4335
let note = NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo: testUserInfo)
4436
apperanceInfo = KeyboardAppearanceInfo(notification: note)
45-
defaultsAppearanceInfo = KeyboardAppearanceInfo(notification: NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo: defaultParsingUserInfo))
37+
let defaultNote = NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo: nil)
38+
defaultsAppearanceInfo = KeyboardAppearanceInfo(notification: defaultNote)
4639
}
4740

4841
func testBeginFrame() {
4942
XCTAssertEqual(apperanceInfo.beginFrame, CGRect(x: 100, y: 100, width: 100, height: 100),
5043
"Parsing beginFrame from keyboard appearance info failed.")
51-
XCTAssertEqual(defaultsAppearanceInfo.beginFrame, CGRectZero)
44+
XCTAssertEqual(defaultsAppearanceInfo.beginFrame, CGRectZero,
45+
"Parsing default beginFrame from keyboard appearance info failed.")
5246
}
5347

5448
func testEndFrame() {
5549
XCTAssertEqual(apperanceInfo.endFrame, CGRect(x: 200, y: 200, width: 200, height: 200),
5650
"Parsing endFrame from keyboard appearance info failed.")
57-
XCTAssertEqual(defaultsAppearanceInfo.endFrame, CGRectZero)
51+
XCTAssertEqual(defaultsAppearanceInfo.endFrame, CGRectZero,
52+
"Parsing default endFrame from keyboard appearance info failed.")
5853
}
5954

6055
@available(iOS 9.0, *)
6156
func testBelongsToCurrentApp() {
6257
XCTAssertEqual(apperanceInfo.belongsToCurrentApp, false,
6358
"Parsing belongsToCurrentApp from keyboard appearance info failed.")
64-
XCTAssertEqual(defaultsAppearanceInfo.belongsToCurrentApp, true)
59+
XCTAssertEqual(defaultsAppearanceInfo.belongsToCurrentApp, true,
60+
"Parsing default belongsToCurrentApp from keyboard appearance info failed.")
6561
}
6662

6763
func testAnimationDuration() {
6864
XCTAssertEqual(apperanceInfo.animationDuration, Double(3),
6965
"Parsing animationDuration from keyboard appearance info failed.")
70-
XCTAssertEqual(defaultsAppearanceInfo.animationDuration, 0.25)
66+
XCTAssertEqual(defaultsAppearanceInfo.animationDuration, Double(0.25),
67+
"Parsing default animationDuration from keyboard appearance info failed.")
7168
}
7269

7370
func testAnimationCurve() {
7471
XCTAssertEqual(apperanceInfo.animationCurve, UIViewAnimationCurve(rawValue: 2),
7572
"Parsing animationCurve from keyboard appearance info failed.")
76-
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve.EaseInOut)
73+
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve(rawValue: defaultsAppearanceInfo.animationCurve.rawValue),
74+
"Parsing default animationCurve from keyboard appearance info failed.")
7775
}
7876

7977
func testAnimateAlong() {

0 commit comments

Comments
 (0)