mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 14:46:56 +02:00
Improve tests
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
@@ -28,6 +29,7 @@ enum MockPollHistoryScreenState: MockScreenState, CaseIterable {
|
||||
case activeEmpty
|
||||
case pastEmpty
|
||||
case loading
|
||||
case loadingWithContent
|
||||
|
||||
/// The associated screen
|
||||
var screenType: Any.Type {
|
||||
@@ -52,7 +54,10 @@ enum MockPollHistoryScreenState: MockScreenState, CaseIterable {
|
||||
pollService.pastPollsData = []
|
||||
case .loading:
|
||||
pollHistoryMode = .active
|
||||
pollService.fetchState = true
|
||||
pollService.isLoadingPublisher = Just(true).eraseToAnyPublisher()
|
||||
case .loadingWithContent:
|
||||
pollHistoryMode = .active
|
||||
pollService.isLoadingPublisher = [false, true].publisher.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
let viewModel = PollHistoryViewModel(mode: pollHistoryMode, pollService: pollService)
|
||||
|
||||
@@ -33,9 +33,9 @@ final class MockPollHistoryService: PollHistoryServiceProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
var fetchState: Bool = false
|
||||
var isLoadingPublisher: AnyPublisher = Just(false).eraseToAnyPublisher()
|
||||
var isFetching: AnyPublisher<Bool, Never> {
|
||||
Just(fetchState).eraseToAnyPublisher()
|
||||
isLoadingPublisher
|
||||
}
|
||||
|
||||
var activePollsData: [TimelinePollDetails] = (1..<10)
|
||||
|
||||
@@ -76,8 +76,7 @@ struct PollHistory: View {
|
||||
private var loadMoreButton: some View {
|
||||
HStack(spacing: 8) {
|
||||
if viewModel.viewState.isLoading {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
spinner
|
||||
}
|
||||
|
||||
Button {
|
||||
@@ -88,6 +87,12 @@ struct PollHistory: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var spinner: some View {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var noPollsView: some View {
|
||||
if viewModel.viewState.canLoadMoreContent {
|
||||
@@ -116,8 +121,7 @@ struct PollHistory: View {
|
||||
|
||||
private var loadingView: some View {
|
||||
HStack(spacing: 8) {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
spinner
|
||||
|
||||
Text(VectorL10n.pollHistoryLoadingText)
|
||||
.font(theme.fonts.body)
|
||||
|
||||
Reference in New Issue
Block a user