Skip to content

Commit

Permalink
Remove skipRepeats() (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinswart authored Mar 26, 2020
1 parent 9ce4d82 commit 95c0cfc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 37 deletions.
1 change: 0 additions & 1 deletion Library/ViewModels/LoadingButtonViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public final class LoadingButtonViewModel:
public init() {
let isLoading = self.isLoadingProperty.signal
.skipNil()
.skipRepeats()

self.isUserInteractionEnabled = isLoading
.negate()
Expand Down
38 changes: 4 additions & 34 deletions Library/ViewModels/LoadingButtonViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,15 @@ final class LoadingButtonViewModelTests: TestCase {
self.vm.outputs.stopLoading.observe(self.stopLoading.observer)
}

func testIsUserInteractionEnabled() {
self.vm.inputs.isLoading(false)
self.isUserInteractionEnabled.assertValues([true])

self.vm.inputs.isLoading(false)
self.isUserInteractionEnabled.assertValues([true])

self.vm.inputs.isLoading(true)
self.isUserInteractionEnabled.assertValues([true, false])

self.vm.inputs.isLoading(true)
self.isUserInteractionEnabled.assertValues([true, false])
}

func testStartLoading() {
self.vm.inputs.isLoading(true)
self.startLoading.assertValueCount(1)

func testIsLoading() {
self.vm.inputs.isLoading(true)
self.isUserInteractionEnabled.assertValues([false])
self.startLoading.assertValueCount(1)
self.stopLoading.assertValueCount(0)

self.vm.inputs.isLoading(false)
self.isUserInteractionEnabled.assertValues([false, true])
self.startLoading.assertValueCount(1)

self.vm.inputs.isLoading(true)
self.startLoading.assertValueCount(2)
}

func testStopLoading() {
self.vm.inputs.isLoading(false)
self.stopLoading.assertValueCount(1)

self.vm.inputs.isLoading(false)
self.stopLoading.assertValueCount(1)

self.vm.inputs.isLoading(true)
self.stopLoading.assertValueCount(1)

self.vm.inputs.isLoading(false)
self.stopLoading.assertValueCount(2)
}
}
1 change: 0 additions & 1 deletion Library/ViewModels/ProjectPamphletMainCellViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public final class ProjectPamphletMainCellViewModel: ProjectPamphletMainCellView
.map { project, variant in
project.rewards.isEmpty && variant == .variant2
}
.skipRepeats()

let shouldTrackCTATappedEvent = projectAndRefTag
.takeWhen(self.readMoreButtonTappedProperty.signal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ final class ProjectPamphletMainCellViewModelTests: TestCase {

self.vm.inputs.configureWith(value: (projectWithRewards, nil, (creatorDetails, false)))

self.readMoreButtonIsLoading.assertValues([true, false])
self.readMoreButtonIsLoading.assertValues([true, false, false])
}
}

Expand Down

0 comments on commit 95c0cfc

Please # to comment.