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
// | |
// Copyright © 2020 maximsmirnov. All rights reserved. | |
// | |
import Entwine | |
public extension Signal { | |
var error: Failure? { | |
guard case .completion(.failure(let error)) = self else { return nil } | |
return error |
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
🛑 failed - Unexpected state mutation: … | |
AppState( | |
todos: [ | |
Todo( | |
− isComplete: false, | |
+ isComplete: true, | |
description: "Milk", | |
id: 00000000-0000-0000-0000-000000000000 | |
), | |
] |
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
private let reducer: (inout State, Action, Environment) -> Effect<Action, Never> |
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
store.assert( | |
.environment { | |
$0.currentDate = { 100 } | |
$0.trainingProcessor = TrainingProcessor( | |
applyGrade: { _, _, _ in flashCard }, | |
nextTraining: { _ in flashCard } | |
) | |
}, | |
.send(.fillTheBlanks(.goNext(grade))), | |
.receive(.trainingCompleted(.bright)) { |
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
struct StateStore { | |
private let scheduler: TestScheduler | |
init( | |
scheduler: TestScheduler, | |
permissionService: (PermissionType) -> Observable<PermissionStatus> = { _ in .never() }, | |
alertModule: (AlertModule.State) -> Observable<GeneralEvent> = { _ in .never() } | |
) | |
} |
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
import RxCocoa | |
import RxSwift | |
import RxTest | |
open class TestStore<State: Core.State, Event>: Store<State, Event> where State.Event == Event { | |
private let observer: TestableObserver<State> | |
private let scheduler: TestScheduler | |
private let disposeBag: DisposeBag | |
public init(scheduler: TestScheduler, |
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
// User wants to open calendar event edit. | |
// User doesn't have permission for editing a calendar. | |
// Request should be sent to the user. | |
// If the user authorized the permission. | |
// Calendar event edit will be opened. | |
// User added new event. -> Calendar State should be saved. And then the scene should be dismissed with Calendar State == nil. | |
// After dismissing dismissedScene should be calendar. | |
func testCalendarUserStoryWithPermission() { | |
// Given | |
let authorizedEvents = [PermissionType.events: PermissionStatus.authorized] |
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
func testAfterDataLoadedEventStateWillBeChangedIntoLoadedWithReceivedData() { | |
// Given | |
let initialState: State = .initial | |
let data = ["first", "second"] | |
// When | |
let resultState = State.reduce(state: initialState, event: .dataLoaded(data: data)) | |
// Then | |
XCTAssertEqual(resultState, .loaded(data: data)) | |
} |
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
extension State { | |
static func reduce(state: State, event: Event) -> State { | |
var state = state | |
switch event { | |
case .dataLoaded(let data): | |
state = .loaded(data: data) | |
case .loadData: | |
state = .loading | |
} | |
return state |
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
func reduce(state: State, event: Event) -> State |
NewerOlder