Skip to content

Commit

Permalink
Fix more UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
alfogrillo committed Jul 12, 2023
1 parent 14907b8 commit 3a1d7d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
18 changes: 6 additions & 12 deletions UnitTests/Sources/BugReportViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ class BugReportViewModelTests: XCTestCase {
}

func testSendReportWithSuccess() async throws {
let expectation = expectation(description: #function)
let mockService = BugReportServiceMock()
mockService.submitBugReportProgressListenerClosure = { _, _ in
await Task.yield()
defer {
expectation.fulfill()
}
return .success(SubmitBugReportResponse(reportUrl: "https://test.test"))
}
let viewModel = BugReportScreenViewModel(bugReportService: mockService,
Expand All @@ -72,17 +75,8 @@ class BugReportViewModelTests: XCTestCase {
screenshot: nil, isModallyPresented: false)
let context = viewModel.context
context.send(viewAction: .submit)

_ = await viewModel
.actions
.values
.first {
guard case .submitFinished = $0 else {
return false
}
return true
}


await fulfillment(of: [expectation])
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, canContact: false, githubLabels: [], files: []))
}
Expand Down
5 changes: 2 additions & 3 deletions UnitTests/Sources/HomeScreenViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ class HomeScreenViewModelTests: XCTestCase {
let room: RoomProxyMock = .init(with: .init(id: mockRoomId, displayName: "Some room"))
room.leaveRoomClosure = { .failure(.failedLeavingRoom) }
clientProxy.roomForIdentifierMocks[mockRoomId] = room
let deferred = deferFulfillment(context.$viewState.first(), message: "viewState should be published.")
context.send(viewAction: .confirmLeaveRoom(roomIdentifier: mockRoomId))
try await deferred.fulfill()
XCTAssertNotNil(context.alertInfo)
let state = await context.nextViewState()
XCTAssertNotNil(state?.bindings.alertInfo)
}

func testLeaveRoomSuccess() async throws {
Expand Down

0 comments on commit 3a1d7d5

Please sign in to comment.