-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
19 deletions.
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
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
85 changes: 85 additions & 0 deletions
85
Projects/Features/SigninFeature/Tests/SigninViewModelSpec.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,85 @@ | ||
import Quick | ||
import Nimble | ||
import Combine | ||
import DomainModule | ||
import DataModule | ||
@testable import SigninFeature | ||
|
||
// swiftlint: disable function_body_length | ||
final class SigninViewModelSpec: QuickSpec { | ||
override func spec() { | ||
var signinUseCase: SigninUseCase! | ||
var sut: SigninViewModel! | ||
|
||
beforeEach { | ||
signinUseCase = SigninUseCaseFake() | ||
sut = SigninViewModel(signinUseCase: signinUseCase) | ||
} | ||
describe("SigninViewModel에서") { | ||
context("유저가 아무것도 입력하지 않은 상태라면") { | ||
it("isSigninButtonEnabled은 false이다.") { | ||
expect { sut.id }.to(beEmpty()) | ||
expect { sut.password }.to(beEmpty()) | ||
expect { sut.isSigninButtonEnabled }.to(beFalse()) | ||
} | ||
} | ||
context("유저가 ID만 입력했다면") { | ||
beforeEach { | ||
sut.id = "A" | ||
} | ||
it("isSigninButtonEnabled은 false이다.") { | ||
expect { sut.id }.toNot(beEmpty()) | ||
expect { sut.password }.to(beEmpty()) | ||
expect { sut.isSigninButtonEnabled }.to(beFalse()) | ||
} | ||
} | ||
context("유저가 Password만 입력했다면") { | ||
beforeEach { | ||
sut.password = "A" | ||
} | ||
it("isSigninButtonEnabled은 false이다.") { | ||
expect { sut.id }.to(beEmpty()) | ||
expect { sut.password }.toNot(beEmpty()) | ||
expect { sut.isSigninButtonEnabled }.to(beFalse()) | ||
} | ||
} | ||
context("유저가 ID와 Password를 모두 입력했다면") { | ||
beforeEach { | ||
sut.id = "A" | ||
sut.password = "A" | ||
} | ||
it("isSigninButtonEnabled은 true이다.") { | ||
expect { sut.id }.toNot(beEmpty()) | ||
expect { sut.password }.toNot(beEmpty()) | ||
expect { sut.isSigninButtonEnabled }.to(beTrue()) | ||
} | ||
} | ||
context("유저가 ID와 Password를 알맞게 입력하고 로그인을 시도한다면") { | ||
beforeEach { | ||
sut.id = "baekteun" | ||
sut.password = "baekteun" | ||
sut.signinButtonDidTap() | ||
} | ||
it("isSuccessSignin이 true이다.") { | ||
expect { sut.isSuccessSignin }.toEventually(beTrue()) | ||
} | ||
} | ||
context("유저가 ID와 Password중 하나라도 알맞지 않게 입력하고 로그인을 시도한다면") { | ||
beforeEach { | ||
sut.id = "ASDF" | ||
sut.password = "ASDF" | ||
sut.signinButtonDidTap() | ||
} | ||
it("isSuccessSignin은 false이다") { | ||
expect { sut.isSuccessSignin }.toEventually(beFalse()) | ||
} | ||
it("isErrorOcuured는 true이다") { | ||
expect { sut.isErrorOcuured }.toEventually(beTrue()) | ||
} | ||
it("errorMessage는 '아이디 또는 비밀번호를 확인해주세요.'가 나온다") { | ||
expect { sut.errorMessage }.toEventually(equal("아이디 또는 비밀번호를 확인해주세요.")) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
Projects/Services/DataModule/Sources/Auth/UseCases/Fake/SigninUseCaseFake.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,21 @@ | ||
import Combine | ||
import DataMappingModule | ||
import DomainModule | ||
import ErrorModule | ||
import Foundation | ||
|
||
public struct SigninUseCaseFake: SigninUseCase { | ||
public init () {} | ||
|
||
public func execute(req: SigninRequestDTO) -> AnyPublisher<Void, DmsError> { | ||
if req.accountID == "baekteun" && req.password == "baekteun" { | ||
return Just(()).setFailureType(to: DmsError.self) | ||
.delay(for: 1, scheduler: DispatchQueue.main) | ||
.eraseToAnyPublisher() | ||
} else { | ||
return Fail(error: DmsError.passwordMismatch) | ||
.delay(for: 1, scheduler: DispatchQueue.main) | ||
.eraseToAnyPublisher() | ||
} | ||
} | ||
} |