Skip to content

Commit

Permalink
2.1.0(#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanshine authored Jun 5, 2018
1 parent f8b53a5 commit 644cb95
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Example/OKTableViewLiaison.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 6FWSRPXBW6;
DevelopmentTeam = 886ZPWDXTP;
LastSwiftMigration = 0900;
};
607FACE41AFB9204008FA782 = {
Expand Down Expand Up @@ -654,7 +654,7 @@
baseConfigurationReference = 23269C76472F62EBE85FEF6A /* Pods-OKTableViewLiaison_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 6FWSRPXBW6;
DEVELOPMENT_TEAM = 886ZPWDXTP;
INFOPLIST_FILE = OKTableViewLiaison/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
Expand All @@ -670,7 +670,7 @@
baseConfigurationReference = F6351EA9623B9FC2F8F18E5E /* Pods-OKTableViewLiaison_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 6FWSRPXBW6;
DEVELOPMENT_TEAM = 886ZPWDXTP;
INFOPLIST_FILE = OKTableViewLiaison/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
Expand Down
38 changes: 27 additions & 11 deletions Example/Tests/OKTableViewLiaison+UnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ final class OKTableViewLiaison_UnitTests: XCTestCase {
if #available(iOS 10.0, *) {
XCTAssert(tableView.prefetchDataSource === liaison)
}
XCTAssert(liaison.tableView == tableView)
}

func test_detachTableView_removesDelegateAndDataSource() {
liaison.detachTableView()
liaison.detach()
XCTAssert(tableView.delegate == nil)
XCTAssert(tableView.dataSource == nil)
if #available(iOS 10.0, *) {
XCTAssert(tableView.prefetchDataSource == nil)
}
XCTAssert(liaison.tableView == nil)
}

func test_toggleIsEditing_togglesTableViewEditingMode() {
Expand Down Expand Up @@ -833,12 +835,11 @@ final class OKTableViewLiaison_UnitTests: XCTestCase {
}

func test_willDisplayCell_paginationDelegateGetsCalled() {
let row = TestTableViewRow()

let delegate = TestTableViewLiaisonPaginationDelegate()

liaison.paginationDelegate = delegate

let section = OKTableViewSection(rows: [row])
let section = OKTableViewSection(rows: [TestTableViewRow()])
liaison.append(section: section)

liaison.tableView(tableView, willDisplay: UITableViewCell(), forRowAt: IndexPath(row: 0, section: 0))
Expand All @@ -853,14 +854,30 @@ final class OKTableViewLiaison_UnitTests: XCTestCase {

waitForExpectations(timeout: 0.2, handler: nil)
}

func test_willDisplayCell_appendsPaginationSection() {
let delegate = TestTableViewLiaisonPaginationDelegate()
liaison.paginationDelegate = delegate

let section = OKTableViewSection(rows: [TestTableViewRow()])
liaison.append(section: section)

let expectation = XCTestExpectation(description: "Adds pagination section")

liaison.tableView(tableView, willDisplay: UITableViewCell(), forRowAt: IndexPath(row: 0, section: 0))

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
XCTAssert(self.liaison.sections.last === self.liaison.paginationSection)
expectation.fulfill()
}

wait(for: [expectation], timeout: 0.5)
}

func test_appendSection_paginationDelegateEndsByAppendingSection() {
let row1 = TestTableViewRow()
let row2 = TestTableViewRow()
let section1 = OKTableViewSection(rows: [row1, row2])
let section1 = OKTableViewSection(rows: [TestTableViewRow(), TestTableViewRow()])
let delegate = TestTableViewLiaisonPaginationDelegate()
let row3 = TestTableViewRow()
let section2 = OKTableViewSection(rows: [row3])
let section2 = OKTableViewSection(rows: [TestTableViewRow()])

liaison.paginationDelegate = delegate
liaison.append(section: section1)
Expand All @@ -882,8 +899,7 @@ final class OKTableViewLiaison_UnitTests: XCTestCase {
}

func test_appendRow_paginationDelegateEndsByAppendingRow() {
let row1 = TestTableViewRow()
let section = OKTableViewSection(rows: [row1])
let section = OKTableViewSection(rows: [TestTableViewRow()])
let delegate = TestTableViewLiaisonPaginationDelegate()
let row2 = TestTableViewRow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final public class OKTableViewLiaison: NSObject {
}
}

public func detachTableView() {
public func detach() {
tableView?.delegate = nil
tableView?.dataSource = nil

Expand Down
2 changes: 1 addition & 1 deletion OKTableViewLiaison/Classes/Rows/OKTableViewRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ open class OKTableViewRow<Cell: UITableViewCell, Model>: OKAnyTableViewRow {
public var indentWhileEditing: Bool
public var deleteConfirmationTitle: String?
public var deleteRowAnimation: UITableViewRowAnimation
public var registrationType: OKTableViewRegistrationType

private let registrationType: OKTableViewRegistrationType
private var commands = [OKTableViewRowCommand: (Cell, Model, IndexPath) -> Void]()
private var heights = [OKTableViewHeightType: (Model) -> CGFloat]()
private var prefetchCommands = [OKTableViewPrefetchCommand: (Model, IndexPath) -> Void]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ open class OKTableViewSectionComponent<View: UITableViewHeaderFooterView, Model>
self.registrationType = registrationType
}

private let model: Model
public let registrationType: OKTableViewRegistrationType

public let model: Model

private let registrationType: OKTableViewRegistrationType
private var commands = [OKTableViewSectionComponentCommand: (View, Model, Int) -> Void]()
private var heights = [OKTableViewHeightType: (Model) -> CGFloat]()

Expand Down

0 comments on commit 644cb95

Please sign in to comment.