Handle multithreaded access crashes on unit tests using generated mocks

- always dispatch receivedInvocations mutations on the main queue
This commit is contained in:
Stefan Ceriu
2024-06-13 13:21:47 +03:00
committed by Stefan Ceriu
parent 8b3141ffec
commit b8dea8ac4e
5 changed files with 912 additions and 304 deletions
@@ -118,10 +118,12 @@ class ComposerToolbarViewModelTests: XCTestCase {
XCTAssertEqual(viewModel.state.suggestions, suggestions)
}
func testSuggestionTrigger() {
func testSuggestionTrigger() async {
wysiwygViewModel.setMarkdownContent("@test")
wysiwygViewModel.setMarkdownContent("#not_implemented_yay")
await Task.yield()
// The first one is nil because when initialised the view model is empty
XCTAssertEqual(completionSuggestionServiceMock.setSuggestionTriggerReceivedInvocations, [nil, .init(type: .user, text: "test", range: .init(location: 0, length: 5)), nil])
}