Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state store mocks #849

Merged
merged 7 commits into from
Oct 3, 2024
Merged

Conversation

tinder-garricnahapetian
Copy link
Contributor

No description provided.

Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Sources/NodesTesting/StoreMocks.swift Outdated Show resolved Hide resolved
Copy link
Collaborator

@tinder-cfuller tinder-cfuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on offline discussions, the decision is to add mocks similar to what this PR was initially introducing, but without the bind methods, as the bind methods will be removed from the protocols on another PR.

For reference:

StateStoreMock.swift:

//
//  Copyright © 2024 Tinder (Match Group, LLC)
//

import Nodes
import SwiftUI

public final class StateStoreMock<State: Equatable>: StateStore, ObservableStateStore {

    public var state: State {
        didSet { stateSetCallCount += 1 }
    }

    public private(set) var stateSetCallCount: Int = 0

    public init(state: State) {
        self.state = state
    }
}

ViewStateStoreMock.swift:

//
//  Copyright © 2024 Tinder (Match Group, LLC)
//

import Nodes
import SwiftUI

public final class ViewStateStoreMock<ViewState: Equatable>: ViewStateStore, ObservableViewStateStore {

    public var viewState: ViewState {
        didSet { viewStateSetCallCount += 1 }
    }

    public private(set) var viewStateSetCallCount: Int = 0

    public init(viewState: ViewState) {
        self.viewState = viewState
    }
}

@tinder-garricnahapetian tinder-garricnahapetian merged commit f482e7e into main Oct 3, 2024
5 checks passed
@tinder-garricnahapetian tinder-garricnahapetian deleted the store-add-stock-mocks branch October 3, 2024 00:25
@tinder-garricnahapetian tinder-garricnahapetian changed the title Add StoreMocks.swift Add State Store mocks Oct 7, 2024
@tinder-garricnahapetian tinder-garricnahapetian changed the title Add State Store mocks Add state store mocks Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants