Created
February 12, 2018 19:04
-
-
Save fabiothiroki/34be895783f0d969411c6b4548eb13a1 to your computer and use it in GitHub Desktop.
Reducer tests
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
class AppReducerSpec: XCTestCase { | |
func testShouldReturnInitialState() { | |
let newState = reducer.reduce(action: FetchPlacesAction(), state: nil) | |
XCTAssertEqual(newState, FetchedPlacesState(places: .loading)) | |
} | |
func testShouldChangeStateAfterSuccessfulRequest() { | |
let places = LocationPlaces() | |
let action = SetPlacesAction.init(places: places) | |
let newState = reducer.reduce(action: action, state: nil) | |
XCTAssertEqual(newState, FetchedPlacesState(places: Result.finished(places))) | |
} | |
func testShouldChangeStateAfterErrorRequest() { | |
let mockError = NSError(domain: "Mock error", code: 42, userInfo: nil ) | |
let action = SetErrorAction(error: mockError) | |
let newState = reducer.reduce(action: action, state: nil) | |
XCTAssertEqual(newState, FetchedPlacesState(places: Result.failed)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment