Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/unit tests #783

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}

}
Loading