From 155ae8f4577a1ccffc5101abc2a8eddec775400b Mon Sep 17 00:00:00 2001 From: Vincent Tourraine Date: Tue, 28 Jun 2016 09:51:19 +0200 Subject: [PATCH] Update acknowledgements sorting for Swift 3 syntax, add test case --- AcknowList.xcodeproj/project.pbxproj | 4 ++ Source/AcknowListViewController.swift | 2 +- Tests/AcknowListViewControllerTests.swift | 12 ++++- Tests/Pods-acknowledgements-multi.plist | 53 +++++++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Tests/Pods-acknowledgements-multi.plist diff --git a/AcknowList.xcodeproj/project.pbxproj b/AcknowList.xcodeproj/project.pbxproj index d9d9995..2c62580 100644 --- a/AcknowList.xcodeproj/project.pbxproj +++ b/AcknowList.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 1AA3C37F1CAC35190071A7FD /* AcknowList.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA3C3741CAC35190071A7FD /* AcknowList.framework */; }; 1AD73B921CAC3B1C0084F8CA /* Pods-acknowledgements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */; }; 1AD73BBE1CAC54C60084F8CA /* AcknowList.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1AD73BBD1CAC54C60084F8CA /* AcknowList.bundle */; }; + D7CCBD131D22624B0013F696 /* Pods-acknowledgements-multi.plist in Resources */ = {isa = PBXBuildFile; fileRef = D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -47,6 +48,7 @@ 1AA3C3851CAC35190071A7FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Pods-acknowledgements.plist"; path = "Tests/Pods-acknowledgements.plist"; sourceTree = SOURCE_ROOT; }; 1AD73BBD1CAC54C60084F8CA /* AcknowList.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = AcknowList.bundle; path = Resources/AcknowList.bundle; sourceTree = SOURCE_ROOT; }; + D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements-multi.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -118,6 +120,7 @@ isa = PBXGroup; children = ( 1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */, + D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */, 1AA3C3851CAC35190071A7FD /* Info.plist */, ); name = "Supporting Files"; @@ -240,6 +243,7 @@ buildActionMask = 2147483647; files = ( 1AD73B921CAC3B1C0084F8CA /* Pods-acknowledgements.plist in Resources */, + D7CCBD131D22624B0013F696 /* Pods-acknowledgements-multi.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/AcknowListViewController.swift b/Source/AcknowListViewController.swift index 0693934..4e6bd2a 100644 --- a/Source/AcknowListViewController.swift +++ b/Source/AcknowListViewController.swift @@ -128,7 +128,7 @@ public class AcknowListViewController: UITableViewController { options: [], range: nil, locale: Locale.current()) - return (result.rawValue == ComparisonResult.orderedAscending.rawValue) + return (result == ComparisonResult.orderedAscending) }) self.acknowledgements = sortedAcknowledgements diff --git a/Tests/AcknowListViewControllerTests.swift b/Tests/AcknowListViewControllerTests.swift index 96a8294..27ef296 100644 --- a/Tests/AcknowListViewControllerTests.swift +++ b/Tests/AcknowListViewControllerTests.swift @@ -14,7 +14,6 @@ import XCTest class AcknowListViewControllerTests: XCTestCase { func testConfigureTableView() { - let bundle = Bundle(for: AcknowListViewControllerTests.self) let plistPath = bundle.pathForResource("Pods-acknowledgements", ofType: "plist") @@ -26,4 +25,15 @@ class AcknowListViewControllerTests: XCTestCase { let cell = viewController.tableView(viewController.tableView, cellForRowAt: IndexPath(row: 0, section: 0)) XCTAssertEqual(cell.textLabel?.text, "AcknowList") } + + func testSortsAcknowledgementsByTitle() { + let bundle = Bundle(for: AcknowListViewControllerTests.self) + let plistPath = bundle.pathForResource("Pods-acknowledgements-multi", ofType: "plist") + + let viewController = AcknowListViewController(acknowledgementsPlistPath: plistPath) + XCTAssertEqual(viewController.acknowledgements?.count, 3) + XCTAssertEqual(viewController.acknowledgements?[0].title, "A title") + XCTAssertEqual(viewController.acknowledgements?[1].title, "B title") + XCTAssertEqual(viewController.acknowledgements?[2].title, "C title") + } } diff --git a/Tests/Pods-acknowledgements-multi.plist b/Tests/Pods-acknowledgements-multi.plist new file mode 100644 index 0000000..908d031 --- /dev/null +++ b/Tests/Pods-acknowledgements-multi.plist @@ -0,0 +1,53 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ... + Title + A title + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ... + Title + C title + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ... + Title + B title + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + +