Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ailinykh committed Aug 15, 2023
1 parent 74c3e11 commit 5de3021
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import ImgurCore
extension ImgurAlbumLoaderUsecaseTests {
func expect(_ sut: ImgurAlbumLoader, toCompleteWith expectedResult: Swift.Result<[Album], ImgurAlbumLoader.Error>, when action: () -> Void, file: StaticString = #filePath, line: UInt = #line) {
let exp = expectation(description: "Wait for upload completion")
let account = Account(token: "a-token", username: "a-username")
let account = Account(
accessToken: "access-token",
refreshToken: "refresh-token",
expiresIn: 86400,
username: "some-username")

sut.load(for: account) { receivedResult in
switch (receivedResult, expectedResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension ImgurAuthProviderUseCaseTests {
sut.authorize { receivedResult in
switch (expectedResult, receivedResult) {
case (.success(let expectedData), .success(let receivedData)):
XCTAssertEqual(expectedData.token, receivedData.token, file: file, line: line)
XCTAssertEqual(expectedData.accessToken, receivedData.accessToken, file: file, line: line)
XCTAssertEqual(expectedData.username, receivedData.username, file: file, line: line)
case (.failure(let expectedError as NSError), .failure(let receivedError as NSError)):
XCTAssertEqual(expectedError, receivedError, file: file, line: line)
Expand Down
6 changes: 5 additions & 1 deletion ImgurCoreTests/ImgurAlbumLoaderUsecaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import XCTest
class ImgurAlbumLoaderUsecaseTests: XCTestCase {
func test_loadSetsAuthorizationTokenForRequest() {
let (sut, client) = makeSUT()
let account = Account(token: "some-token", username: "some-username")
let account = Account(
accessToken: "some-token",
refreshToken: "refresh-token",
expiresIn: 86400,
username: "some-username")

sut.load(for: account) { _ in }

Expand Down
8 changes: 6 additions & 2 deletions ImgurCoreTests/ImgurAuthProviderUseCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class ImgurAuthProviderUseCaseTests: XCTestCase {

func test_authorize_deliversAuthData() {
let (sut, client) = makeSUT()
let url = URL(string: "https://an-url.com/#access_token=some-token&account_username=some-name")!
let authData = Account(token: "some-token", username: "some-name")
let url = URL(string: "https://an-url.com/#access_token=some-token&account_username=some-name&refresh_token=refresh-token&expires_in=86400")!
let authData = Account(
accessToken: "some-token",
refreshToken: "refresh-token",
expiresIn: 86400,
username: "some-name")
expect(sut, toCompleteWith: .success(authData)) {
client.complete(with: .success(url))
}
Expand Down
2 changes: 1 addition & 1 deletion ImgurCoreTests/ImgurUploaderUseCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ImgurUploaderUseCaseTests: XCTestCase {
private func makeSUT() -> (sut: ImgurUploader, client: HTTPClientSpy) {
let client = HTTPClientSpy()
let builder = RequestBuilderStub()
let sut = ImgurUploader(client: client, clientId: "SECRET_CLIENT_ID", builder: builder)
let sut = ImgurUploader(client: client, auth: .clientId("SECRET_CLIENT_ID"), builder: builder)
return (sut, client)
}
}
Expand Down

0 comments on commit 5de3021

Please sign in to comment.