almost finished getting tests to work

This commit is contained in:
Ryan Nystrom
2017-05-21 17:39:32 -04:00
parent dcdf83c383
commit fbd310ceed
3 changed files with 16 additions and 113 deletions

View File

@@ -62,7 +62,6 @@
29A1950C1EC7901400C3E289 /* NotificationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A1950B1EC7901400C3E289 /* NotificationType.swift */; };
29A195111EC7AC9500C3E289 /* NotificationRepoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195101EC7AC9500C3E289 /* NotificationRepoCell.swift */; };
29A195131EC7AD2D00C3E289 /* RepoNotificationsSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195121EC7AD2D00C3E289 /* RepoNotificationsSectionController.swift */; };
29A195191EC7AF6800C3E289 /* NotificationsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195181EC7AF6800C3E289 /* NotificationsTests.swift */; };
29A4768A1ECFEC55005D0953 /* IssueCommentSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A476891ECFEC55005D0953 /* IssueCommentSectionController.swift */; };
29A4768C1ECFED5E005D0953 /* IssueCommentDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4768B1ECFED5E005D0953 /* IssueCommentDetailsViewModel.swift */; };
29A4768E1ED07A23005D0953 /* DateDetailsFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4768D1ED07A23005D0953 /* DateDetailsFormatter.swift */; };
@@ -75,6 +74,12 @@
29A4769C1ED0DEE2005D0953 /* IssueLabelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769B1ED0DEE2005D0953 /* IssueLabelCell.swift */; };
29A4769E1ED0E083005D0953 /* Label+IGListDiffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769D1ED0E083005D0953 /* Label+IGListDiffable.swift */; };
29A476A01ED0E6C6005D0953 /* UIColor+Overlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769F1ED0E6C6005D0953 /* UIColor+Overlay.swift */; };
29A476A11ED23F83005D0953 /* DateDetailsFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4768D1ED07A23005D0953 /* DateDetailsFormatter.swift */; };
29A476A51ED23FA2005D0953 /* Authorization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297AE8601EC0D5C100B44A1F /* Authorization.swift */; };
29A476A61ED23FAE005D0953 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297AE85F1EC0D5C100B44A1F /* App.swift */; };
29A476A71ED23FBA005D0953 /* Label+IGListDiffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769D1ED0E083005D0953 /* Label+IGListDiffable.swift */; };
29A476A81ED23FC4005D0953 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C9FDB71EC65FEE00EE3A52 /* Label.swift */; };
29A476AA1ED24032005D0953 /* ListTestKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C295091EC7AFA500D46CD2 /* ListTestKit.swift */; };
29C0E7071ECBC6C50051D756 /* GithubClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C0E7061ECBC6C50051D756 /* GithubClient.swift */; };
29C167671ECA005500439D62 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C167661ECA005500439D62 /* Strings.swift */; };
29C167691ECA016500439D62 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C167681ECA016500439D62 /* EmptyView.swift */; };
@@ -94,8 +99,6 @@
29C295041EC7AF8C00D46CD2 /* NotificationType+Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195091EC78B4800C3E289 /* NotificationType+Icon.swift */; };
29C295051EC7AF8C00D46CD2 /* NotificationRepoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195101EC7AC9500C3E289 /* NotificationRepoCell.swift */; };
29C295061EC7AF8C00D46CD2 /* NotificationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A1950B1EC7901400C3E289 /* NotificationType.swift */; };
29C295071EC7AF8C00D46CD2 /* RepoNotificationsSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195121EC7AD2D00C3E289 /* RepoNotificationsSectionController.swift */; };
29C2950A1EC7AFA500D46CD2 /* ListTestKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C295091EC7AFA500D46CD2 /* ListTestKit.swift */; };
29C2950B1EC7B16800D46CD2 /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C9FDE01EC667AE00EE3A52 /* Styles.swift */; };
29C2950C1EC7B16C00D46CD2 /* UIColor+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A195011EC66B8B00C3E289 /* UIColor+Hex.swift */; };
29C2950E1EC7B43B00D46CD2 /* ListKitTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C2950D1EC7B43B00D46CD2 /* ListKitTestCase.swift */; };
@@ -199,7 +202,6 @@
29A1950D1EC791BD00C3E289 /* LabelPopover.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = LabelPopover.playground; sourceTree = "<group>"; };
29A195101EC7AC9500C3E289 /* NotificationRepoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationRepoCell.swift; sourceTree = "<group>"; };
29A195121EC7AD2D00C3E289 /* RepoNotificationsSectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepoNotificationsSectionController.swift; sourceTree = "<group>"; };
29A195181EC7AF6800C3E289 /* NotificationsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsTests.swift; sourceTree = "<group>"; };
29A476891ECFEC55005D0953 /* IssueCommentSectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueCommentSectionController.swift; sourceTree = "<group>"; };
29A4768B1ECFED5E005D0953 /* IssueCommentDetailsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueCommentDetailsViewModel.swift; sourceTree = "<group>"; };
29A4768D1ED07A23005D0953 /* DateDetailsFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateDetailsFormatter.swift; sourceTree = "<group>"; };
@@ -307,7 +309,6 @@
children = (
297AE84C1EC0D58A00B44A1F /* DateDisplayTests.swift */,
297AE84E1EC0D58A00B44A1F /* Info.plist */,
29A195181EC7AF6800C3E289 /* NotificationsTests.swift */,
29C2950D1EC7B43B00D46CD2 /* ListKitTestCase.swift */,
29C295091EC7AFA500D46CD2 /* ListTestKit.swift */,
);
@@ -855,21 +856,24 @@
29C167761ECA0DE100439D62 /* NSAttributedStringSizing.swift in Sources */,
29C2950E1EC7B43B00D46CD2 /* ListKitTestCase.swift in Sources */,
29C167721ECA0D7C00439D62 /* UIView+BottomBorder.swift in Sources */,
29C2950A1EC7AFA500D46CD2 /* ListTestKit.swift in Sources */,
29C2950B1EC7B16800D46CD2 /* Styles.swift in Sources */,
29C167751ECA0DC300439D62 /* GithubAPIDateFormatter.swift in Sources */,
29C295061EC7AF8C00D46CD2 /* NotificationType.swift in Sources */,
29C295031EC7AF8C00D46CD2 /* NotificationViewModel.swift in Sources */,
29C295051EC7AF8C00D46CD2 /* NotificationRepoCell.swift in Sources */,
29A195051EC75F3D00C3E289 /* Date+Display.swift in Sources */,
29A476A61ED23FAE005D0953 /* App.swift in Sources */,
29A476A71ED23FBA005D0953 /* Label+IGListDiffable.swift in Sources */,
29C295101EC7B7FF00D46CD2 /* ShowMoreDetailsLabel.swift in Sources */,
29A476A51ED23FA2005D0953 /* Authorization.swift in Sources */,
29C1676C1ECA0D6700439D62 /* RepoNotifications+Filter.swift in Sources */,
29C167711ECA0D7C00439D62 /* Strings.swift in Sources */,
29C295071EC7AF8C00D46CD2 /* RepoNotificationsSectionController.swift in Sources */,
29A476AA1ED24032005D0953 /* ListTestKit.swift in Sources */,
29C2950C1EC7B16C00D46CD2 /* UIColor+Hex.swift in Sources */,
29A476A11ED23F83005D0953 /* DateDetailsFormatter.swift in Sources */,
297AE84D1EC0D58A00B44A1F /* DateDisplayTests.swift in Sources */,
29C167701ECA0D7C00439D62 /* EmptyView.swift in Sources */,
29A195191EC7AF6800C3E289 /* NotificationsTests.swift in Sources */,
29A476A81ED23FC4005D0953 /* Label.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -1,101 +0,0 @@
//
// NotificationsTests.swift
// Freetime
//
// Created by Ryan Nystrom on 5/13/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import XCTest
class NotificationsTests: ListKitTestCase {
override func setUp() {
super.setUp()
kit.sectionControllerBlock = { _ in
return RepoNotificationsSectionController()
}
}
func test_withOneNotification() {
let notification = NotificationViewModel(
title: "Notification 1 title",
type: .issue,
date: Date(),
read: false,
containerWidth: 320
)
let repo = RepoNotifications(repoName: "Repo Name", notifications: [notification])
kit.objects = [repo]
let expect = expectation(description: #function)
kit.adapter.performUpdates(animated: false) { _ in
expect.fulfill()
XCTAssertEqual(self.kit.collectionView.numberOfSections, 1)
XCTAssertEqual(self.kit.collectionView.numberOfItems(inSection: 0), 2)
let titleCell = self.kit.collectionView.cellForItem(at: IndexPath(item: 0, section: 0)) as! NotificationRepoCell
XCTAssertEqual(titleCell.label.text, "Repo Name")
let notificationCell = self.kit.collectionView.cellForItem(at: IndexPath(item: 1, section: 0)) as! NotificationCell
XCTAssertEqual(notificationCell.titleLabel.text, "Notification 1 title")
}
waitForExpectations(timeout: 10, handler: nil)
}
func test_whenFilteringNotifications() {
let repos = [
RepoNotifications(repoName: "Repo 1", notifications: [
NotificationViewModel(
title: "Notification 1-1",
type: .issue,
date: Date(timeIntervalSinceNow: -1),
read: true,
containerWidth: 320
),
NotificationViewModel(
title: "Notification 1-2",
type: .issue,
date: Date(timeIntervalSinceNow: -2),
read: false,
containerWidth: 320
),
NotificationViewModel(
title: "Notification 1-3",
type: .issue,
date: Date(timeIntervalSinceNow: -3),
read: true,
containerWidth: 320
),
]),
RepoNotifications(repoName: "Repo 2", notifications: [
NotificationViewModel(
title: "Notification 2-1",
type: .issue,
date: Date(timeIntervalSinceNow: -1),
read: true,
containerWidth: 320
),
NotificationViewModel(
title: "Notification 2-2",
type: .issue,
date: Date(timeIntervalSinceNow: -2),
read: true,
containerWidth: 320
),
])
]
let all = filter(repoNotifications: repos, unread: false)
XCTAssertEqual(all.count, 2)
XCTAssertEqual(all[0].notifications.count, 3)
XCTAssertEqual(all[1].notifications.count, 2)
let unread = filter(repoNotifications: repos, unread: true)
XCTAssertEqual(unread.count, 1)
XCTAssertEqual(unread[0].notifications.count, 1)
}
}

View File

@@ -5,12 +5,12 @@ use_frameworks!
pod 'IGListKit', :git => 'https://github.com/Instagram/IGListKit.git', :branch => 'master'
pod 'SnapKit', '~> 3.2.0'
pod 'Alamofire', '~> 4.4.0'
pod 'SDWebImage', '~> 4.0.0'
pod '1PasswordExtension', '~> 1.8.4'
pod 'JDStatusBarNotification', '~> 1.5.5'
target 'Freetime' do
pod 'Alamofire', '~> 4.4.0'
pod 'SDWebImage', '~> 4.0.0'
pod '1PasswordExtension', '~> 1.8.4'
pod 'JDStatusBarNotification', '~> 1.5.5'
end
target 'FreetimeTests' do