Skip to content

Instantly share code, notes, and snippets.

@fabiothiroki
Created January 23, 2018 21:52
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 fabiothiroki/23394b775c8a950cd6e0a2180ea2227b to your computer and use it in GitHub Desktop.
Save fabiothiroki/23394b775c8a950cd6e0a2180ea2227b to your computer and use it in GitHub Desktop.
NearbyPlacesServiceSpec
class NearbyPlacesServiceSpec: XCTestCase {
private var container: Container!
private var placesDatasource: PlacesApiMock!
private var userLocationDatasource: UserLocationServiceMock!
private var nearbyPlacesService: NearbyPlacesService!
private let disposeBag = DisposeBag()
override func setUp() {
super.setUp()
// Omited the properties initalization
}
func testShouldRequestPlacesNearbyUserLocation() {
_ = nearbyPlacesService.fetchNearbyPlaces()
.subscribe(onNext: { (places) in
XCTAssertNotNil(places)
}, onError: { (_) in
XCTFail("Should not return error")
}).disposed(by: disposeBag)
let mockUserLatitude = userLocationDatasource.location.coordinate.latitude
let mockUserLongitude = userLocationDatasource.location.coordinate.longitude
XCTAssertEqual(placesDatasource.requestedLatitude, mockUserLatitude)
XCTAssertEqual(placesDatasource.requestedLongitude, mockUserLongitude)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment