Skip to content

Commit

Permalink
Adjust loansDetailDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Feb 25, 2024
1 parent 8b6b40e commit 8e4d0f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class LoansDetailDatasource: NSObject, UITableViewDataSource {
private var lentMe: [CardDTO] = []
private var borrowed: [CardDTO] = []

required init(tableView: UITableView, delegate: LoansDetailsProtocol) {
required init(tableView: UITableView, delegate: LoansDetailsProtocol?) {
super.init()
self.tableView = tableView
self.delegate = delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ final class LoanDetailTableView: UITableView, LoanDetailViewType {

var didSelectCard: ((CardDTO, AddCardType) -> Void)?
var didSelectAddItem: ((AddCardType) -> Void)?


weak var loansDetailDelegate: LoansDetailsProtocol?

private var tableViewDatasource: LoansDetailDatasource?

required init(frame: CGRect = .zero, style: UITableView.Style = .plain, delegate: LoansDetailsProtocol) {
override init(frame: CGRect = .zero, style: UITableView.Style = .plain) {
super.init(frame: frame, style: style)
self.delegate = self
tableViewDatasource = LoansDetailDatasource(tableView: self, delegate: delegate)
backgroundColor = .blackWhite
}

Expand All @@ -28,6 +29,7 @@ final class LoanDetailTableView: UITableView, LoanDetailViewType {
}

func updateTableViewData(person: PersonDTO) {
tableViewDatasource = LoansDetailDatasource(tableView: self, delegate: loansDetailDelegate)
tableViewDatasource?.updateTableViewData(person: person)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class LoanDetailTableViewTests: XCTestCase {
override func setUp() {
super.setUp()
delegate = LoansDetailsPresenterSpy()
sut = LoanDetailTableView(frame: .testDevice, delegate: delegate)
sut = LoanDetailTableView(frame: .testDevice)
let cards: [CardDTO] = [
.stub(),
.stub()
]

sut.loansDetailDelegate = delegate
sut.updateTableViewData(person: .stub(lentMe: cards,
borrowed: cards))
}
Expand Down

0 comments on commit 8e4d0f9

Please sign in to comment.