diff --git a/NetworkInfrastructure/NetworkInfrastructureTests/Services/AccountClientTests.swift b/NetworkInfrastructure/NetworkInfrastructureTests/Services/AccountClientTests.swift index f3b412ff..a51ef9a1 100644 --- a/NetworkInfrastructure/NetworkInfrastructureTests/Services/AccountClientTests.swift +++ b/NetworkInfrastructure/NetworkInfrastructureTests/Services/AccountClientTests.swift @@ -17,7 +17,6 @@ final class AccountClientTests: XCTestCase { try super.setUpWithError() urlSession = MockURLSession() accountClient = AccountClient(session: urlSession) - } override func tearDownWithError() throws { @@ -108,4 +107,45 @@ final class AccountClientTests: XCTestCase { wait(for: [expectation], timeout: 1.0) } + func testGetRecommendedListSuccess() 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 recommended list success") + // Act + accountClient.getRecommendedList(page: 1, accessToken: "", accountId: "") { result in + switch result { + case .success: + break + case .failure: + XCTFail("Get recommended list error") + } + expectation.fulfill() + } + // Assert + wait(for: [expectation], timeout: 1.0) + } + + func testGetRecommendedListError() throws { + // Arrange + urlSession.dataTaskWithRequestCompletionHandler = (nil, nil, nil) + let expectation = XCTestExpectation(description: "Get recommended list error") + // Act + accountClient.getRecommendedList(page: 1, accessToken: "", accountId: "") { result in + switch result { + case .success: + XCTFail("Get recommended list success") + case .failure: + break + } + expectation.fulfill() + } + // Assert + wait(for: [expectation], timeout: 1.0) + } + }