FRANotificationsTableViewControllerTests.m revision a3970d0ea62388e4ede01470a6436eb5c6c92353
3980N/A * Distribution License (the License). You may not use this file except in compliance with the
3980N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
3980N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
3980N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
3980N/A#import <OCMock/OCMock.h>
3980N/A#import <UIKit/UIKit.h>
3980N/A#import <XCTest/XCTest.h>
@end
- (void)setUp {
[super setUp];
viewController = [storyboard instantiateViewControllerWithIdentifier:@"NotificationsTableViewController"];
- (void)tearDown {
[super tearDown];
- (void)testShowsNoNotificationsIfThereAreNone {
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:PENDING_SECTION], 0);
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:COMPLETED_SECTION], 0);
XCTAssertEqualObjects([viewController tableView:viewController.tableView titleForHeaderInSection:PENDING_SECTION], @"");
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:PENDING_SECTION], 2);
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:COMPLETED_SECTION], 0);
XCTAssertEqualObjects([viewController tableView:viewController.tableView titleForHeaderInSection:COMPLETED_SECTION], @"COMPLETED");
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:PENDING_SECTION], 0);
XCTAssertEqual([viewController tableView:viewController.tableView numberOfRowsInSection:COMPLETED_SECTION], 2);
- (void)testShowsDetailsOfPendingNotification {
FRANotification *pendingNotification = [self pendingNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-15.0]];
XCTAssertEqualObjects([viewController tableView:viewController.tableView willSelectRowAtIndexPath:notificationIndexPath], notificationIndexPath);
- (void)testShowsDetailsOfApprovedNotification {
FRANotification *approvedNotification = [self approvedNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-15.0]];
XCTAssertEqualObjects([viewController tableView:viewController.tableView willSelectRowAtIndexPath:notificationIndexPath], nil);
- (void)testShowsDetailsOfDeniedNotification {
FRANotification *deniedNotification = [self deniedNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-15.0]];
XCTAssertEqualObjects([viewController tableView:viewController.tableView willSelectRowAtIndexPath:notificationIndexPath], nil);
FRANotification *firstNotification = [self pendingNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-15.0]];
FRANotification *secondNotification = [self pendingNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-240.0]];
FRANotification *thirdNotification = [self pendingNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-300.0]];
// NB. Add notifications out of order to confirm that they get sorted after retrieval from the push mechanism
FRANotificationTableViewCell *firstCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:PENDING_SECTION]];
FRANotificationTableViewCell *secondCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:PENDING_SECTION]];
FRANotificationTableViewCell *thirdCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:PENDING_SECTION]];
FRANotification *firstNotification = [self approvedNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-15.0]];
FRANotification *secondNotification = [self deniedNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-240.0]];
FRANotification *thirdNotification = [self approvedNotificationReceivedAt:[NSDate dateWithTimeIntervalSinceNow:-300.0]];
// NB. Add notifications out of order to confirm that they get sorted after retrieval from the push mechanism
FRANotificationTableViewCell *firstCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:COMPLETED_SECTION]];
FRANotificationTableViewCell *secondCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:COMPLETED_SECTION]];
FRANotificationTableViewCell *thirdCell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:COMPLETED_SECTION]];
- (void)simulateLoadingOfView {
- (void)simulateUnloadingOfView {
return notification;
return notification;
return (FRANotificationTableViewCell *)
@end