[Framework] Feed List improvements (#19)
This PR contains the work done to improve the overall implementation of the `FeedListViewModel` view model in the `Feed` framework by utilising unit tests. Reviewed-on: rock-n-code/app-reviews#19 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #19.
This commit is contained in:
@@ -118,7 +118,7 @@ final class FeedListViewController: UIViewController {
|
||||
registerTableCells()
|
||||
bindViewModel()
|
||||
|
||||
viewModel.fetch()
|
||||
Task { await viewModel.fetch() }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -170,7 +170,7 @@ private extension FeedListViewController {
|
||||
|
||||
// MARK: Actions
|
||||
@objc func refresh(_ sender: AnyObject) {
|
||||
self.viewModel.fetch()
|
||||
Task { await self.viewModel.fetch() }
|
||||
}
|
||||
|
||||
// MARK: Functions
|
||||
@@ -264,7 +264,7 @@ private extension FeedListViewController {
|
||||
)
|
||||
: nil,
|
||||
action: isErrorState
|
||||
? { self.viewModel.fetch() }
|
||||
? { Task { await self.viewModel.fetch() } }
|
||||
: nil
|
||||
)
|
||||
|
||||
@@ -455,53 +455,7 @@ import ReviewsiTunesKit
|
||||
#Preview("Feed List with few reviews") {
|
||||
MockURLProtocol.response = .init(
|
||||
statusCode: 200,
|
||||
object: Feed(entries: [
|
||||
.init(
|
||||
id: 1,
|
||||
author: "Some author name #1 here",
|
||||
title: "Some review title #1 goes here...",
|
||||
content: "Some long, explanatory review comment #1 goes here...",
|
||||
rating: 3,
|
||||
version: "v1.0.0",
|
||||
updated: .init()
|
||||
),
|
||||
.init(
|
||||
id: 2,
|
||||
author: "Some author name #2 here",
|
||||
title: "Some review title #2 goes here...",
|
||||
content: "Some long, explanatory review comment #2 goes here...",
|
||||
rating: 5,
|
||||
version: "v1.0.0",
|
||||
updated: .init()
|
||||
),
|
||||
.init(
|
||||
id: 3,
|
||||
author: "Some author name #3 here",
|
||||
title: "Some review title #3 goes here...",
|
||||
content: "Some long, explanatory review comment #3 goes here...",
|
||||
rating: 1,
|
||||
version: "v1.0.0",
|
||||
updated: .init()
|
||||
),
|
||||
.init(
|
||||
id: 4,
|
||||
author: "Some author name #4 here",
|
||||
title: "Some review title #4 goes here...",
|
||||
content: "Some long, explanatory review comment #4 goes here...",
|
||||
rating: 4,
|
||||
version: "v1.0.0",
|
||||
updated: .init()
|
||||
),
|
||||
.init(
|
||||
id: 5,
|
||||
author: "Some author name #5 here",
|
||||
title: "Some review title #5 goes here...",
|
||||
content: "Some long, explanatory review comment #5 goes here...",
|
||||
rating: 2,
|
||||
version: "v1.0.0",
|
||||
updated: .init()
|
||||
),
|
||||
])
|
||||
object: Feed(entries: .sample)
|
||||
)
|
||||
|
||||
return UINavigationController(rootViewController: FeedListViewController(.init(
|
||||
|
||||
Reference in New Issue
Block a user