mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
added view in timeline action, added tests
This commit is contained in:
+10
-14
@@ -18,21 +18,17 @@ import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class PollHistoryDetailUITests: MockScreenTestCase {
|
||||
func testPollHistoryDetailPromptRegular() {
|
||||
let promptType = PollHistoryDetailPromptType.regular
|
||||
app.goToScreenWithIdentifier(MockPollHistoryDetailScreenState.promptType(promptType).title)
|
||||
|
||||
let title = app.staticTexts["title"]
|
||||
XCTAssert(title.exists)
|
||||
XCTAssertEqual(title.label, promptType.title)
|
||||
func testPollHistoryDetailOpenPoll() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryDetailScreenState.openDisclosed.title)
|
||||
XCTAssert(app.staticTexts["Active polls"].exists)
|
||||
XCTAssert(app.staticTexts["1/1/01"].exists)
|
||||
XCTAssert(app.buttons["View poll in timeline"].exists)
|
||||
}
|
||||
|
||||
func testPollHistoryDetailPromptUpgrade() {
|
||||
let promptType = PollHistoryDetailPromptType.upgrade
|
||||
app.goToScreenWithIdentifier(MockPollHistoryDetailScreenState.promptType(promptType).title)
|
||||
|
||||
let title = app.staticTexts["title"]
|
||||
XCTAssert(title.exists)
|
||||
XCTAssertEqual(title.label, promptType.title)
|
||||
func testPollHistoryDetailClosedPoll() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryDetailScreenState.closedDisclosed.title)
|
||||
XCTAssert(app.staticTexts["Past polls"].exists)
|
||||
XCTAssert(app.staticTexts["1/1/01"].exists)
|
||||
XCTAssert(app.buttons["View poll in timeline"].exists)
|
||||
}
|
||||
}
|
||||
|
||||
+19
-13
@@ -27,22 +27,28 @@ class PollHistoryDetailViewModelTests: XCTestCase {
|
||||
var context: PollHistoryDetailViewModelType.Context!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
viewModel = PollHistoryDetailViewModel(promptType: .regular, initialCount: Constants.counterInitialValue)
|
||||
|
||||
let answerOptions = [TimelinePollAnswerOption(id: "1", text: "1", count: 1, winner: false, selected: false),
|
||||
TimelinePollAnswerOption(id: "2", text: "2", count: 1, winner: false, selected: false),
|
||||
TimelinePollAnswerOption(id: "3", text: "3", count: 1, winner: false, selected: false)]
|
||||
|
||||
let timelinePoll = TimelinePollDetails(id: "poll-id",
|
||||
question: "Question",
|
||||
answerOptions: answerOptions,
|
||||
closed: false,
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 3,
|
||||
type: .disclosed,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
hasDecryptionError: false)
|
||||
|
||||
viewModel = PollHistoryDetailViewModel(timelineViewModel: TimelinePollViewModel(timelinePollDetails: timelinePoll))
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
func testInitialState() {
|
||||
XCTAssertEqual(context.viewState.count, Constants.counterInitialValue)
|
||||
}
|
||||
|
||||
func testCounter() throws {
|
||||
context.send(viewAction: .incrementCount)
|
||||
XCTAssertEqual(context.viewState.count, 1)
|
||||
|
||||
context.send(viewAction: .incrementCount)
|
||||
XCTAssertEqual(context.viewState.count, 2)
|
||||
|
||||
context.send(viewAction: .decrementCount)
|
||||
XCTAssertEqual(context.viewState.count, 1)
|
||||
XCTAssertFalse(context.viewState.isPollClosed)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user