Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skywinder committed Nov 11, 2014
1 parent 0d5923f commit 032b72b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import <XCTest/XCTest.h>
#import <CoreActionSheetPicker/CoreActionSheetPicker.h>
#import "AbstractActionSheetPicker+CustomButton.h"

static const int countdownTestInt = 360;
UIView *origin;

@interface ActionSheetDatePickerTestCase : XCTestCase
Expand Down Expand Up @@ -134,6 +136,35 @@ - (void)testPickerWithNilCustomActionSelectorOnButtonNilTargetAndNilString
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testPickerCountDownTimerModeValueWithSelector
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil target:self action:@selector(countDownTest:) origin:origin cancelAction:nil];
_actionSheetDatePicker.countDownDuration = countdownTestInt;
[_actionSheetDatePicker showActionSheetPicker];
[_actionSheetDatePicker pressDoneButton];

XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testPickerCountDownTimerModeValueWithBlock
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil doneBlock:^(ActionSheetDatePicker *picker, id selectedDate, id origin) {
XCTAssertEqualObjects(selectedDate, @(countdownTestInt));
} cancelBlock:nil origin:origin];

_actionSheetDatePicker.countDownDuration = countdownTestInt;
[_actionSheetDatePicker showActionSheetPicker];
UIDatePicker *picker = (UIDatePicker *)_actionSheetDatePicker.pickerView;
[_actionSheetDatePicker pressDoneButton];

XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)countDownTest:(NSNumber *)number
{
XCTAssertEqualObjects(number, @(countdownTestInt));
}

- (void)exampleSelector
{
NSLog(@"Test selector invoked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

- (void)pressFirstCustomButton;

- (void)pressDoneButton;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ - (void)pressFirstCustomButton
);
}

- (void)pressDoneButton
{
//6 items in _actionSheetDatePicker.toolbar.items : [ cancel - custom - separator - title - separator - done ]
//So, check custom button:
UIBarButtonItem *customBarButton = self.toolbar.items[4];
SuppressPerformSelectorLeakWarning (
[customBarButton.target performSelector:customBarButton.action withObject:customBarButton];
);
}

@end

0 comments on commit 032b72b

Please sign in to comment.