Skip to content

Instantly share code, notes, and snippets.

@devxoul
Created March 31, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devxoul/99f13897aacf43fdfe8c5050da30e72f to your computer and use it in GitHub Desktop.
Save devxoul/99f13897aacf43fdfe8c5050da30e72f to your computer and use it in GitHub Desktop.
func testAction_refresh() {
// 1. Stub 리액터를 준비합니다.
let reactor = MyReactor()
reactor.stub.isEnabled = true
// 2. Stub된 리액터를 주입한 뷰를 준비합니다.
let view = MyView()
view.reactor = reactor
// 3. 사용자 인터랙션을 발생시킵니다.
view.refreshControl.sendActions(for: .valueChanged)
// 4. Reactor에 액션이 잘 전달되었는지를 검증합니다.
XCTAssertEqual(reactor.stub.actions.last, .refresh)
}
func testState_isLoading() {
// 1. Stub 리액터를 준비합니다.
let reactor = MyReactor()
reactor.stub.isEnabled = true
// 2. Stub된 리액터를 주입한 뷰를 준비합니다.
let view = MyView()
view.reactor = reactor
// 3. 리액터의 상태를 임의로 설정합니다.
reactor.stub.state.value = MyReactor.State(isLoading: true)
// 4. 그 때 뷰 컴포넌트의 속성이 잘 변하는지를 검증합니다.
XCTAssertEqual(view.activityIndicator.isAnimating, true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment