Skip to content

Commit

Permalink
Merge pull request #783 from DeluxeAlonso/feature/unit-tests
Browse files Browse the repository at this point in the history
Feature/unit tests
  • Loading branch information
DeluxeAlonso committed Sep 8, 2023
2 parents 73b1963 + d49f7ae commit efff36e
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,45 @@ final class AccountClientTests: XCTestCase {
wait(for: [expectation], timeout: 1.0)
}

func testCustomListMoviesSuccess() throws {
// Arrange
let data = try JSONEncoder().encode(MovieResult(results: [], currentPage: 1, totalPages: 1))
guard let url = URL(string: "www.google.com") else {
XCTFail("Invalid URL")
return
}
urlSession.dataTaskWithRequestCompletionHandler = (data, HTTPURLResponse(url: url, statusCode: 200, httpVersion: nil, headerFields: nil), nil)
let expectation = XCTestExpectation(description: "Get custom list movies success")
// Act
accountClient.getCustomListMovies(with: "", listId: "") { result in
switch result {
case .success:
break
case .failure:
XCTFail("Get custom list movies error")
}
expectation.fulfill()
}
// Assert
wait(for: [expectation], timeout: 1.0)
}

func testCustomListMoviesError() throws {
// Arrange
urlSession.dataTaskWithRequestCompletionHandler = (nil, nil, nil)
let expectation = XCTestExpectation(description: "Get custom list movies error")
// Act
accountClient.getCustomListMovies(with: "", listId: "") { result in
switch result {
case .success:
XCTFail("Get custom list movies success")
case .failure:
break
}
expectation.fulfill()
}
// Assert
wait(for: [expectation], timeout: 1.0)
}

}

0 comments on commit efff36e

Please sign in to comment.