-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from neilpa/datepicker
Disable broken UIDatePicker test
- Loading branch information
Showing
3 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// UIDatePicker.swift | ||
// Rex | ||
// | ||
// Created by Guido Marucci Blas on 3/25/16. | ||
// Copyright © 2016 Neil Pankey. All rights reserved. | ||
// | ||
import UIKit | ||
import ReactiveCocoa | ||
|
||
extension UIDatePicker { | ||
|
||
public var rex_date: MutableProperty<NSDate> { | ||
let initial = { (picker: UIDatePicker) -> NSDate in | ||
picker.addTarget(self, action: "rex_changedDate", forControlEvents: .ValueChanged) | ||
return picker.date | ||
} | ||
return associatedProperty(self, key: &dateKey, initial: initial) { $0.date = $1 } | ||
} | ||
|
||
@objc | ||
private func rex_changedDate() { | ||
rex_date.value = date | ||
} | ||
|
||
} | ||
|
||
private var dateKey: UInt8 = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// UIDatePickerTests.swift | ||
// Rex | ||
// | ||
// Created by Guido Marucci Blas on 3/25/16. | ||
// Copyright © 2016 Neil Pankey. All rights reserved. | ||
// | ||
|
||
import ReactiveCocoa | ||
import UIKit | ||
import XCTest | ||
import Rex | ||
|
||
class UIDatePickerTests: XCTestCase { | ||
|
||
var date: NSDate! | ||
var picker: UIDatePicker! | ||
|
||
override func setUp() { | ||
let formatter = NSDateFormatter() | ||
formatter.dateFormat = "MM/dd/YYYY" | ||
date = formatter.dateFromString("11/29/1988")! | ||
|
||
picker = UIDatePicker(frame: CGRectZero) | ||
} | ||
|
||
func testUpdatePickerFromProperty() { | ||
picker.rex_date.value = date | ||
|
||
XCTAssertEqual(picker.date, date) | ||
} | ||
|
||
// FIXME Can this actually be made to work inside XCTest? | ||
func _testUpdatePropertyFromPicker() { | ||
let expectation = self.expectationWithDescription("Expected rex_date to send an event when picker's date value is changed by a UI event") | ||
defer { self.waitForExpectationsWithTimeout(2, handler: nil) } | ||
|
||
picker.rex_date.signal.observeNext { changedDate in | ||
XCTAssertEqual(changedDate, self.date) | ||
expectation.fulfill() | ||
} | ||
|
||
picker.date = date | ||
picker.enabled = true | ||
picker.userInteractionEnabled = true | ||
picker.sendActionsForControlEvents(.ValueChanged) | ||
} | ||
|
||
} |