Skip to content

Commit db44c1b

Browse files
committed
Fix the protocol for NavigationRow
1 parent dcb8afc commit db44c1b

6 files changed

Lines changed: 22 additions & 8 deletions

File tree

QuickTableViewController-iOSTests/Row/NavigationRowSpec.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ internal final class NavigationRowSpec: QuickSpec {
4343
expect(row.subtitle) == subtitle
4444
expect(row.icon) == icon
4545
expect(row.cellReuseIdentifier) == "UITableViewCell.subtitle"
46-
expect(row.action).notTo(beNil())
4746

4847
row.action?(row)
4948
expect(invoked) == true
5049
}
50+
51+
it("should conform to the protocol") {
52+
expect(row).to(beAKindOf(NavigationRowCompatible.self))
53+
}
5154
}
5255

5356
describe("cellReuseIdentifier") {

QuickTableViewController-iOSTests/Row/OptionRowSpec.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ internal final class OptionRowSpec: QuickSpec {
4242
expect(row.title) == "title"
4343
expect(row.subtitle).to(beNil())
4444
expect(row.isSelected) == true
45-
expect(row.action).notTo(beNil())
45+
46+
row.action?(row)
47+
expect(invoked) == true
4648

4749
// RowStyle
4850
expect(row.cellReuseIdentifier) == "UITableViewCell"
@@ -51,9 +53,10 @@ internal final class OptionRowSpec: QuickSpec {
5153
expect(row.accessoryType) == UITableViewCellAccessoryType.checkmark
5254
expect(row.isSelectable) == true
5355
expect(row.customize).to(beNil())
56+
}
5457

55-
row.action?(row)
56-
expect(invoked) == true
58+
it("should conform to the protocol") {
59+
expect(row).to(beAKindOf(OptionRowCompatible.self))
5760
}
5861
}
5962

@@ -103,6 +106,7 @@ internal final class OptionRowSpec: QuickSpec {
103106

104107
it("should invoke the action closure") {
105108
row.isSelected = true
109+
expect(row.accessoryType) == UITableViewCellAccessoryType.checkmark
106110
expect(invoked).toEventually(beTrue())
107111
}
108112
}
@@ -113,6 +117,7 @@ internal final class OptionRowSpec: QuickSpec {
113117

114118
it("should not invoke the action closure") {
115119
row.isSelected = false
120+
expect(row.accessoryType) == UITableViewCellAccessoryType.none
116121
expect(invoked).toEventually(beFalse())
117122
}
118123
}

QuickTableViewController-iOSTests/Row/SwitchRowSpec.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ internal final class SwitchRowSpec: QuickSpec {
3939
expect(row.title) == "title"
4040
expect(row.switchValue) == true
4141
expect(row.cellReuseIdentifier) == "SwitchCell"
42-
expect(row.action).notTo(beNil())
4342

4443
row.action?(row)
4544
expect(invoked) == true
4645
}
46+
47+
it("should conform to the protocol") {
48+
expect(row).to(beAKindOf(SwitchRowCompatible.self))
49+
}
4750
}
4851

4952
describe("equatable") {

QuickTableViewController-iOSTests/Row/TapActionRowSpec.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ internal final class TapActionRowSpec: QuickSpec {
3838
it("should initialize with given parameters") {
3939
expect(row.title) == "title"
4040
expect(row.cellReuseIdentifier) == "TapActionCell"
41-
expect(row.action).notTo(beNil())
4241

4342
row.action?(row)
4443
expect(invoked) == true
4544
}
45+
46+
it("should conform to the protocol") {
47+
expect(row).to(beAKindOf(TapActionRowCompatible.self))
48+
}
4649
}
4750

4851
describe("equatable") {

Source/Protocol/RowCompatible.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import Foundation
2828

2929
/// This protocol defines the compatible interface of a `NavigationRow` regardless of its associated cell type.
30-
public protocol NavigationRowCompatible: class, Row, RowStyle {}
30+
public protocol NavigationRowCompatible: Row, RowStyle {}
3131

3232

3333
/// This protocol defines the compatible interface of a `TapActionRow` regardless of its associated cell type.

Source/Rows/NavigationRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import UIKit
2828

2929
/// A class that represents a row that triggers certain navigation when selected.
30-
open class NavigationRow<T: UITableViewCell>: Row, RowStyle, Equatable {
30+
open class NavigationRow<T: UITableViewCell>: NavigationRowCompatible, Equatable {
3131

3232
// MARK: - Initializer
3333

0 commit comments

Comments
 (0)