Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save giovani-pereira-ifood/8f71362c034f425b4a41d9f814cee834 to your computer and use it in GitHub Desktop.
Save giovani-pereira-ifood/8f71362c034f425b4a41d9f814cee834 to your computer and use it in GitHub Desktop.
class MyViewTests: XCTestCase {
private let delegateSpy = DelegateSpy()
private lazy var sut = {
let sut = MyView()
sut.delegate = delegateSpy
return sut
}()
func test_pressingActionButton_shouldCallDelegate() {
perform(.touchUpInside, from: sut.actionButton, target: sut, args: nil)
XCTAssertTrue(delegateSpy.actionCalled)
}
func test_tappingView_shouldCallDelegate() {
performGestureRecognizer(ofType: UITapGestureRecognizer.self, on: sut)
XCTAssertTrue(delegateSpy.viewTappedCalled)
}
func test_longPressingView_shouldCallDelegate() {
performGestureRecognizer(ofType: UILongPressGestureRecognizer.self, on: sut)
XCTAssertTrue(delegateSpy.longPressedCalled)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment