-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FXIOS-10481 [Unified Search] Add SearchEngineSelection middleware…
… tests and a Redux MockStoreForMiddleware (#23065) * Stub in preliminary middleware tests and mock Store for middleware. Finish writing SearchEngineSelectionMiddlewareTests. * Extend the StoreTestUtilityHelper to accept a mock Store. Update usage across unit tests. Add StoreTestUtility conformance to SearchEngineSelectionMiddlewareTests. * Round out the SearchEnginesManager mock, update usages, and use in the SearchEngineSelectionMiddlewareTests.
- Loading branch information
Showing
12 changed files
with
160 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
...x-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockStoreForMiddleware.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import Redux | ||
|
||
@testable import Client | ||
|
||
/// A mock Store used to test redux middlewares. | ||
/// | ||
/// If you need to highly customize this mock to meet your testing needs, you should subclass it and/or make your own mock | ||
/// store implementation (e.g. storing a completion handler for asynchronous middleware actions so you can await expectations | ||
/// in your tests). | ||
class MockStoreForMiddleware<State: StateType>: DefaultDispatchStore { | ||
var state: State | ||
|
||
/// Records the number of times dispatch is called, and the actions with which it is called. Check this property to | ||
/// ensure that your middleware correctly dispatches the right action(s) in response to a given action. | ||
var dispatchCalled: (numberOfTimes: Int, withActions: [Redux.Action]) = (0, []) | ||
|
||
init(state: State) { | ||
self.state = state | ||
} | ||
|
||
func subscribe<S>(_ subscriber: S) where S: Redux.StoreSubscriber, State == S.SubscriberStateType { | ||
// TODO if you need it | ||
} | ||
|
||
func subscribe<SubState, S>( | ||
_ subscriber: S, | ||
transform: ( | ||
( | ||
Redux.Subscription<State> | ||
) -> Redux.Subscription<SubState> | ||
)? | ||
) where SubState == S.SubscriberStateType, S: Redux.StoreSubscriber { | ||
// TODO if you need it | ||
} | ||
|
||
func unsubscribe<S>(_ subscriber: S) where S: Redux.StoreSubscriber, State == S.SubscriberStateType { | ||
// TODO if you need it | ||
} | ||
|
||
func unsubscribe(_ subscriber: any Redux.StoreSubscriber) { | ||
// TODO if you need it | ||
} | ||
|
||
func dispatch(_ action: Redux.Action) { | ||
var dispatchActions = dispatchCalled.withActions | ||
dispatchActions.append(action) | ||
|
||
dispatchCalled = (dispatchCalled.numberOfTimes + 1, dispatchActions) | ||
} | ||
} |
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
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
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
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
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
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