Skip to content

Commit

Permalink
Improve AddToDeckPresenter unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Apr 25, 2024
1 parent b2f4e47 commit 5a22946
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -40,6 +40,7 @@ final class AddToDeckPresenterTests: XCTestCase {
override func tearDown() {
client = nil
service = nil
navigationController = nil
sut = nil
super.tearDown()
}
Expand All @@ -54,13 +55,23 @@ final class AddToDeckPresenterTests: XCTestCase {
}

@MainActor
func test_retrieveAllCardsfailing() async {
func test_retrieveAllCards_failing() async {
client.error = true
sut.retrieveAllCards()

XCTAssertEqual(view.didCallStartLoading, 1)
// XCTAssertEqual(view.didCallStopLoading, 1)
// XCTAssertEqual(view.didCallShowNetworkErrorMessage, 1)
let expectation = XCTestExpectation(description: "Retrieve all cards expectation")

Task {
sut.retrieveAllCards()
expectation.fulfill()
}

await fulfillment(of: [expectation])

await MainActor.run {
XCTAssertEqual(view.didCallStartLoading, 1)
XCTAssertEqual(view.didCallStopLoading, 1)
// XCTAssertEqual(view.didCallShowNetworkErrorMessage, 1)
}
}

func test_insert_card_into_deck_database_successfuly() {
Expand Down

0 comments on commit 5a22946

Please sign in to comment.