-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? # to your account
[NT-644] See all project category fix #1061
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7be7004
see all category button works on thanks page
cdolm92 4cd5c54
wip- removed unnecessary code
cdolm92 0567fca
wip- tests
cdolm92 5a0b41a
swiftlint fix
cdolm92 a73f8af
datasource test fix
cdolm92 8cfe43b
Merge branch 'master' of https://github.com/kickstarter/ios-oss into β¦
cdolm92 3a6ad87
naming fixed
cdolm92 02f244e
updated names in tests
cdolm92 8a83566
Merge branch 'master' of https://github.com/kickstarter/ios-oss into β¦
cdolm92 fb298e9
swiftformat
cdolm92 8ba1411
changed guard
cdolm92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Foundation | ||
import KsApi | ||
import Prelude | ||
import ReactiveExtensions | ||
import ReactiveSwift | ||
|
||
public protocol ThanksCategoryCellViewModelInputs { | ||
func seeAllProjectsButtonTapped() | ||
func configureWith(category: KsApi.Category) | ||
} | ||
|
||
public protocol ThanksCategoryCellViewModelOutputs { | ||
var notifyDelegateToGoToDiscovery: Signal<KsApi.Category, Never> { get } | ||
var seeAllProjectCategoryTitle: Signal<String, Never> { get } | ||
} | ||
|
||
public protocol ThanksCategoryCellViewModelType { | ||
var inputs: ThanksCategoryCellViewModelInputs { get } | ||
var outputs: ThanksCategoryCellViewModelOutputs { get } | ||
} | ||
|
||
public final class ThanksCategoryCellViewModel: ThanksCategoryCellViewModelType, | ||
ThanksCategoryCellViewModelInputs, ThanksCategoryCellViewModelOutputs { | ||
public init() { | ||
let projectCategory = self.categoryProperty.signal.skipNil() | ||
|
||
self.seeAllProjectCategoryTitle = projectCategory.map { | ||
Strings.See_all_category_name_projects(category_name: $0.name) | ||
} | ||
|
||
self.notifyDelegateToGoToDiscovery = projectCategory | ||
.takeWhen(self.seeAllProjectsButtonTappedProperty.signal) | ||
} | ||
|
||
fileprivate let categoryProperty = MutableProperty<KsApi.Category?>(nil) | ||
public func configureWith(category: KsApi.Category) { | ||
self.categoryProperty.value = category | ||
} | ||
|
||
fileprivate let seeAllProjectsButtonTappedProperty = MutableProperty(()) | ||
public func seeAllProjectsButtonTapped() { | ||
self.seeAllProjectsButtonTappedProperty.value = () | ||
} | ||
|
||
public let seeAllProjectCategoryTitle: Signal<String, Never> | ||
public let notifyDelegateToGoToDiscovery: Signal<KsApi.Category, Never> | ||
|
||
public var inputs: ThanksCategoryCellViewModelInputs { return self } | ||
public var outputs: ThanksCategoryCellViewModelOutputs { return self } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@testable import KsApi | ||
import Library | ||
import Prelude | ||
import ReactiveExtensions_TestHelpers | ||
import XCTest | ||
|
||
final class ThanksCategoryCellViewModelTests: TestCase { | ||
private let notifyDelegateToGoToDiscovery = TestObserver<KsApi.Category, Never>() | ||
private let seeAllProjectCategoryTitle = TestObserver<String, Never>() | ||
private let vm = ThanksCategoryCellViewModel() | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
self.vm.notifyDelegateToGoToDiscovery.observe(self.notifyDelegateToGoToDiscovery.observer) | ||
self.vm.seeAllProjectCategoryTitle.observe(self.seeAllProjectCategoryTitle.observer) | ||
} | ||
|
||
func testNotifyDelegate() { | ||
let category = Category.template | ||
|
||
self.vm.inputs.configureWith(category: category) | ||
self.notifyDelegateToGoToDiscovery.assertDidNotEmitValue() | ||
self.vm.inputs.seeAllProjectsButtonTapped() | ||
self.notifyDelegateToGoToDiscovery.assertDidEmitValue() | ||
} | ||
|
||
func testSeeAllProjectCategoryButtonTitle() { | ||
let category = Category.template | ||
|> Category.lens.name .~ "Art" | ||
|
||
self.vm.inputs.configureWith(category: category) | ||
self.seeAllProjectCategoryTitle.assertValues(["See all Art projects"]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is an existing input but could also be good to align this naming with the delegate method naming once that's updated π€·ββ