Skip to content

Instantly share code, notes, and snippets.

@mAu888
Last active February 21, 2016 14:22
Show Gist options
  • Save mAu888/681d013a1c120ca7894f to your computer and use it in GitHub Desktop.
Save mAu888/681d013a1c120ca7894f to your computer and use it in GitHub Desktop.
class ProfileViewModelTests: XCTestCase {
func testDelegateNotifiedWhenProfileDeleted_Refactored() {
// given
let (viewModel, _, delegate) = initializedViewModel()
// when
viewModel.deleteProfile()
// then
XCTAssert(delegate.didDeleteUser)
}
// MARK: - Helpers
private func initializedViewModel() -> (ProfileViewModel, FakeAPIClient, FakeDelegate) {
let fakeClient = FakeAPIClient()
let delegate = FakeDelegate()
let viewModel = ProfileViewModel(apiClient: fakeClient, delegate: delegate)
return (viewModel, fakeClient, delegate)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment