-
Notifications
You must be signed in to change notification settings - Fork 8
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
🔀 :: (#458) ArtistReactor Unit Test 작성 #466
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Projects/Domains/ArtistDomain/Testing/UseCase/FetchArtistListUseCaseSpy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ArtistDomainInterface | ||
import Foundation | ||
import RxSwift | ||
|
||
public final class FetchArtistListUseCaseSpy: FetchArtistListUseCase { | ||
public private(set) var callCount = 0 | ||
public var handler: (() -> Single<[ArtistListEntity]>) = { .never() } | ||
public func execute() -> Single<[ArtistListEntity]> { | ||
callCount += 1 | ||
return handler() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
Projects/Features/ArtistFeature/Tests/ArtistReactorTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import ArtistDomainInterface | ||
@testable import ArtistDomainTesting | ||
@testable import ArtistFeature | ||
import XCTest | ||
|
||
final class ArtistReactorTests: XCTestCase { | ||
var fetchArtistListUseCase: FetchArtistListUseCaseSpy! | ||
var sut: ArtistReactor! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
fetchArtistListUseCase = .init() | ||
sut = ArtistReactor(fetchArtistListUseCase: fetchArtistListUseCase) | ||
} | ||
|
||
override func tearDown() { | ||
super.tearDown() | ||
fetchArtistListUseCase = nil | ||
sut = nil | ||
} | ||
|
||
func test_when_viewDidLoad_action_and_artist_count_is_1_then_append_hidden_item() { | ||
// Given | ||
let dummyArtistList = [makeTwoDummyArtistList().first!] | ||
fetchArtistListUseCase.handler = { | ||
return .just(dummyArtistList) | ||
} | ||
|
||
// When | ||
sut.action.onNext(.viewDidLoad) | ||
|
||
// Then | ||
XCTAssertEqual(fetchArtistListUseCase.callCount, 1) | ||
XCTAssertEqual(sut.currentState.artistList[0], dummyArtistList.first) | ||
XCTAssertEqual(sut.currentState.artistList[1].artistId, "") | ||
XCTAssertEqual(sut.currentState.artistList[1].isHiddenItem, true) | ||
} | ||
|
||
func test_when_viewDidLoad_action_and_artist_count_greater_than_2_then_swap_index_0_and_1() { | ||
// Given | ||
let dummyArtistList = makeTwoDummyArtistList() | ||
fetchArtistListUseCase.handler = { | ||
return .just(dummyArtistList) | ||
} | ||
let expectedArtistList = { | ||
var list = dummyArtistList | ||
list.swapAt(0, 1) | ||
return list | ||
}() | ||
|
||
// When | ||
sut.action.onNext(.viewDidLoad) | ||
|
||
// Then | ||
XCTAssertEqual(fetchArtistListUseCase.callCount, 1) | ||
XCTAssertEqual(sut.currentState.artistList, expectedArtistList) | ||
} | ||
|
||
private func makeTwoDummyArtistList() -> [ArtistListEntity] { | ||
[ | ||
ArtistListEntity( | ||
artistId: "1", | ||
name: "name", | ||
short: "short", | ||
group: "group", | ||
title: "title", | ||
description: "description", | ||
color: [["ffffff"]], | ||
youtube: "https://youtube.com", | ||
twitch: "twitch", | ||
instagram: "insta", | ||
imageRoundVersion: 1, | ||
imageSquareVersion: 1, | ||
graduated: false, | ||
isHiddenItem: false | ||
), | ||
ArtistListEntity( | ||
artistId: "2", | ||
name: "nam2", | ||
short: "short2", | ||
group: "group2", | ||
title: "title2", | ||
description: "description2", | ||
color: [["ffffff"]], | ||
youtube: "https://youtube.com", | ||
twitch: "twitch", | ||
instagram: "insta", | ||
imageRoundVersion: 1, | ||
imageSquareVersion: 1, | ||
graduated: false, | ||
isHiddenItem: false | ||
) | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확실히 많이 기네요 ㅎㅎ....
아니면 테스트 함수만큼은 한글 네이밍을 해보는 건 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트에 필요하다고 생각하는 라이브러리들 고민한번 해주시고 다음 테스트 작성 때 저도 따라 가겠습니다.