- library updated - overrides for the dependencies are now done in the trailing closures - some tests were split to so they cover only 1 case (not 2 cases in one test) - TCA debug trace back again
This commit is contained in:
parent
c8b97a8266
commit
665c792808
|
@ -2522,7 +2522,7 @@
|
|||
repositoryURL = "https://github.com/pointfreeco/swift-composable-architecture";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 0.45.0;
|
||||
version = 0.46.0;
|
||||
};
|
||||
};
|
||||
9E2AC0FD27D8EC120042AA47 /* XCRemoteSwiftPackageReference "MnemonicSwift" */ = {
|
||||
|
|
|
@ -77,8 +77,8 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-composable-architecture",
|
||||
"state" : {
|
||||
"revision" : "1fcd53fc875bade47d850749ea53c324f74fd64d",
|
||||
"version" : "0.45.0"
|
||||
"revision" : "52dca7e5edd6ec9e0b529380843a8cb13f57d7d7",
|
||||
"version" : "0.46.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -454,7 +454,7 @@ extension AppStore {
|
|||
static var placeholder: AppStore {
|
||||
AppStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
reducer: AppReducer()._printChanges()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,16 +86,16 @@ class AppInitializationTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: appState,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.databaseFiles = .noOp
|
||||
store.dependencies.databaseFiles.areDbFilesPresentFor = { _ in true }
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.mnemonic = .mock
|
||||
store.dependencies.randomRecoveryPhrase = recoveryPhraseRandomizer
|
||||
store.dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
store.dependencies.walletStorage.areKeysPresent = { true }
|
||||
) { dependencies in
|
||||
dependencies.databaseFiles = .noOp
|
||||
dependencies.databaseFiles.areDbFilesPresentFor = { _ in true }
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.mnemonic = .mock
|
||||
dependencies.randomRecoveryPhrase = recoveryPhraseRandomizer
|
||||
dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
dependencies.walletStorage.areKeysPresent = { true }
|
||||
}
|
||||
|
||||
// Root of the test, the app finished the launch process and triggers the checks and initializations.
|
||||
store.send(.appDelegate(.didFinishLaunching))
|
||||
|
@ -144,12 +144,12 @@ class AppInitializationTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.databaseFiles = .noOp
|
||||
store.dependencies.databaseFiles.areDbFilesPresentFor = { _ in true }
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.walletStorage = .noOp
|
||||
) { dependencies in
|
||||
dependencies.databaseFiles = .noOp
|
||||
dependencies.databaseFiles.areDbFilesPresentFor = { _ in true }
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.walletStorage = .noOp
|
||||
}
|
||||
|
||||
// Root of the test, the app finished the launch process and triggers the checks and initializations.
|
||||
store.send(.appDelegate(.didFinishLaunching))
|
||||
|
@ -177,11 +177,11 @@ class AppInitializationTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.databaseFiles = .noOp
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.walletStorage = .noOp
|
||||
) { dependencies in
|
||||
dependencies.databaseFiles = .noOp
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.walletStorage = .noOp
|
||||
}
|
||||
|
||||
// Root of the test, the app finished the launch process and triggers the checks and initializations.
|
||||
store.send(.appDelegate(.didFinishLaunching))
|
||||
|
|
|
@ -62,9 +62,9 @@ class AppTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
) {
|
||||
$0.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
}
|
||||
|
||||
store.send(.respondToWalletInitializationState(.uninitialized))
|
||||
|
||||
|
@ -91,10 +91,10 @@ class AppTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.walletStorage = .noOp
|
||||
store.dependencies.walletStorage.exportWallet = { throw "export failed" }
|
||||
) { dependencies in
|
||||
dependencies.walletStorage = .noOp
|
||||
dependencies.walletStorage.exportWallet = { throw "export failed" }
|
||||
}
|
||||
|
||||
store.send(.respondToWalletInitializationState(.filesMissing)) { state in
|
||||
state.appInitializationState = .filesMissing
|
||||
|
@ -112,10 +112,10 @@ class AppTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.walletStorage = .noOp
|
||||
store.dependencies.walletStorage.exportWallet = { throw "export failed" }
|
||||
) { dependencies in
|
||||
dependencies.walletStorage = .noOp
|
||||
dependencies.walletStorage.exportWallet = { throw "export failed" }
|
||||
}
|
||||
|
||||
store.send(.respondToWalletInitializationState(.initialized))
|
||||
|
||||
|
|
|
@ -11,12 +11,14 @@ import ComposableArchitecture
|
|||
|
||||
class RecoveryPhraseDisplayReducerTests: XCTestCase {
|
||||
func testCopyToBuffer() {
|
||||
let testPasteboard = PasteboardClient.testPasteboard
|
||||
|
||||
let store = TestStore(
|
||||
initialState: RecoveryPhraseDisplayStore.test,
|
||||
reducer: RecoveryPhraseDisplayReducer()
|
||||
)
|
||||
|
||||
store.dependencies.pasteboard = .testPasteboard
|
||||
) {
|
||||
$0.pasteboard = testPasteboard
|
||||
}
|
||||
|
||||
store.send(.copyToBufferPressed) {
|
||||
$0.phrase = .placeholder
|
||||
|
@ -24,7 +26,7 @@ class RecoveryPhraseDisplayReducerTests: XCTestCase {
|
|||
}
|
||||
|
||||
XCTAssertEqual(
|
||||
store.dependencies.pasteboard.getString(),
|
||||
testPasteboard.getString(),
|
||||
RecoveryPhrase.placeholder.toString()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -82,14 +82,14 @@ class DeeplinkTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: appState,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
|
||||
store.dependencies.deeplink = DeeplinkClient(
|
||||
resolveDeeplinkURL: { _, _ in Deeplink.Route.home }
|
||||
)
|
||||
let synchronizer = NoopSDKSynchronizer()
|
||||
synchronizer.updateStateChanged(.synced)
|
||||
store.dependencies.sdkSynchronizer = synchronizer
|
||||
) { dependencies in
|
||||
dependencies.deeplink = DeeplinkClient(
|
||||
resolveDeeplinkURL: { _, _ in Deeplink.Route.home }
|
||||
)
|
||||
let synchronizer = NoopSDKSynchronizer()
|
||||
synchronizer.updateStateChanged(.synced)
|
||||
dependencies.sdkSynchronizer = synchronizer
|
||||
}
|
||||
|
||||
guard let url = URL(string: "zcash:///home") else {
|
||||
return XCTFail("Deeplink: 'testDeeplinkRequest_homeURL' URL is expected to be valid.")
|
||||
|
@ -125,16 +125,16 @@ class DeeplinkTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: appState,
|
||||
reducer: AppReducer()
|
||||
)
|
||||
) { dependencies in
|
||||
dependencies.deeplink = DeeplinkClient(
|
||||
resolveDeeplinkURL: { _, _ in Deeplink.Route.send(amount: 123_000_000, address: "address", memo: "some text") }
|
||||
)
|
||||
dependencies.sdkSynchronizer = synchronizer
|
||||
}
|
||||
|
||||
guard let url = URL(string: "zcash:///home/send?address=address&memo=some%20text&amount=123000000") else {
|
||||
return XCTFail("Deeplink: 'testDeeplinkRequest_sendURL_amount' URL is expected to be valid.")
|
||||
}
|
||||
|
||||
store.dependencies.deeplink = DeeplinkClient(
|
||||
resolveDeeplinkURL: { _, _ in Deeplink.Route.send(amount: 123_000_000, address: "address", memo: "some text") }
|
||||
)
|
||||
store.dependencies.sdkSynchronizer = synchronizer
|
||||
|
||||
_ = await store.send(.deeplink(url))
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ class HomeTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: HomeReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
) { dependencies in
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
}
|
||||
|
||||
store.send(.synchronizerStateChanged(.synced))
|
||||
|
||||
|
@ -129,9 +129,9 @@ class HomeTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: HomeReducer()
|
||||
)
|
||||
|
||||
store.dependencies.diskSpaceChecker = .mockEmptyDisk
|
||||
) {
|
||||
$0.diskSpaceChecker = .mockEmptyDisk
|
||||
}
|
||||
|
||||
store.send(.onAppear) { state in
|
||||
state.requiredTransactionConfirmations = 10
|
||||
|
@ -151,9 +151,9 @@ class HomeTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: HomeReducer()
|
||||
)
|
||||
|
||||
store.dependencies.diskSpaceChecker = .mockFullDisk
|
||||
) {
|
||||
$0.diskSpaceChecker = .mockFullDisk
|
||||
}
|
||||
|
||||
store.send(.onAppear) { state in
|
||||
state.requiredTransactionConfirmations = 10
|
||||
|
|
|
@ -26,10 +26,10 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
) { dependencies in
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$importedSeedPhrase, "one two three"))) { state in
|
||||
state.importedSeedPhrase = "one two three"
|
||||
|
@ -42,10 +42,10 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
) { dependencies in
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$importedSeedPhrase, "a a a a a a a a a a a a a a a a a a a a a a a a"))) { state in
|
||||
state.importedSeedPhrase = "a a a a a a a a a a a a a a a a a a a a a a a a"
|
||||
|
@ -59,9 +59,9 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
) {
|
||||
$0.mnemonic = .noOp
|
||||
}
|
||||
|
||||
store.send(
|
||||
.binding(
|
||||
|
@ -147,10 +147,10 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
) { dependencies in
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$birthdayHeight, "1700000"))) { state in
|
||||
state.birthdayHeight = "1700000"
|
||||
|
@ -173,10 +173,10 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
) { dependencies in
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.mnemonic.isValid = { _ in throw "invalid mnemonic" }
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$birthdayHeight, "1600000"))) { state in
|
||||
state.birthdayHeight = "1600000"
|
||||
|
@ -198,9 +198,9 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
) {
|
||||
$0.mnemonic = .noOp
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$birthdayHeight, "1600000"))) { state in
|
||||
state.birthdayHeight = "1600000"
|
||||
|
@ -239,9 +239,9 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
) {
|
||||
$0.mnemonic = .noOp
|
||||
}
|
||||
|
||||
store.send(.binding(.set(\.$birthdayHeight, "1700000"))) { state in
|
||||
state.birthdayHeight = "1700000"
|
||||
|
@ -281,9 +281,9 @@ class ImportWalletTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ImportWalletReducer.State(maxWordsCount: 24),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
) {
|
||||
$0.mnemonic = .noOp
|
||||
}
|
||||
|
||||
store.send(
|
||||
.binding(
|
||||
|
@ -332,10 +332,10 @@ class ImportWalletTests: XCTestCase {
|
|||
birthdayHeightValue: 1_700_000
|
||||
),
|
||||
reducer: ImportWalletReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.walletStorage = .noOp
|
||||
) { dependencies in
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.walletStorage = .noOp
|
||||
}
|
||||
|
||||
store.send(.restoreWallet) { state in
|
||||
state.alert = AlertState(
|
||||
|
|
|
@ -14,10 +14,10 @@ class ProfileTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: ProfileReducer()
|
||||
)
|
||||
|
||||
store.dependencies.appVersion = .mock
|
||||
store.dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
) { dependencies in
|
||||
dependencies.appVersion = .mock
|
||||
dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
}
|
||||
|
||||
store.send(.onAppear) { state in
|
||||
state.address = "ff3927e1f83df9b1b0dc75540ddc59ee435eecebae914d2e6dfe8576fbedc9a8"
|
||||
|
|
|
@ -291,7 +291,9 @@ class RecoveryPhraseValidationTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: currentStep,
|
||||
reducer: RecoveryPhraseValidationFlowReducer()
|
||||
)
|
||||
) {
|
||||
$0.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
}
|
||||
|
||||
let expectedMissingWordChips = [
|
||||
PhraseChip.Kind.empty,
|
||||
|
@ -307,8 +309,6 @@ class RecoveryPhraseValidationTests: XCTestCase {
|
|||
ValidationWord(groupIndex: 3, word: "pizza")
|
||||
]
|
||||
|
||||
store.dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
|
||||
store.send(.move(wordChip: PhraseChip.Kind.unassigned(word: "pizza"), intoGroup: 3)) {
|
||||
$0.missingWordChips = expectedMissingWordChips
|
||||
$0.validationWords = expectedValidationWords
|
||||
|
@ -363,7 +363,10 @@ class RecoveryPhraseValidationTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: currentStep,
|
||||
reducer: RecoveryPhraseValidationFlowReducer()
|
||||
)
|
||||
) { dependencies in
|
||||
dependencies.feedbackGenerator = .noOp
|
||||
dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
}
|
||||
|
||||
let expectedMissingWordChips = [
|
||||
PhraseChip.Kind.empty,
|
||||
|
@ -379,9 +382,6 @@ class RecoveryPhraseValidationTests: XCTestCase {
|
|||
ValidationWord(groupIndex: 3, word: "pizza")
|
||||
]
|
||||
|
||||
store.dependencies.feedbackGenerator = .noOp
|
||||
store.dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
|
||||
store.send(.move(wordChip: PhraseChip.Kind.unassigned(word: "pizza"), intoGroup: 3)) {
|
||||
$0.missingWordChips = expectedMissingWordChips
|
||||
$0.validationWords = expectedValidationWords
|
||||
|
|
|
@ -21,9 +21,9 @@ class ScanTests: XCTestCase {
|
|||
scanStatus: .value("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")
|
||||
),
|
||||
reducer: ScanReducer()
|
||||
)
|
||||
|
||||
store.dependencies.captureDevice = .noOp
|
||||
) {
|
||||
$0.captureDevice = .noOp
|
||||
}
|
||||
|
||||
store.send(.onAppear) { state in
|
||||
state.isTorchAvailable = false
|
||||
|
@ -37,9 +37,9 @@ class ScanTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ScanReducer.State(),
|
||||
reducer: ScanReducer()
|
||||
)
|
||||
|
||||
store.dependencies.captureDevice = .noOp
|
||||
) {
|
||||
$0.captureDevice = .noOp
|
||||
}
|
||||
|
||||
store.send(.torchPressed) { state in
|
||||
state.isTorchOn = true
|
||||
|
@ -52,9 +52,9 @@ class ScanTests: XCTestCase {
|
|||
isTorchOn: true
|
||||
),
|
||||
reducer: ScanReducer()
|
||||
)
|
||||
|
||||
store.dependencies.captureDevice = .noOp
|
||||
) {
|
||||
$0.captureDevice = .noOp
|
||||
}
|
||||
|
||||
store.send(.torchPressed) { state in
|
||||
state.isTorchOn = false
|
||||
|
@ -65,9 +65,9 @@ class ScanTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ScanReducer.State(),
|
||||
reducer: ScanReducer()
|
||||
)
|
||||
|
||||
store.dependencies.uriParser.isValidURI = { _ in false }
|
||||
) {
|
||||
$0.uriParser.isValidURI = { _ in false }
|
||||
}
|
||||
|
||||
store.send(.scan("test")) { state in
|
||||
state.scanStatus = .value("test")
|
||||
|
@ -81,10 +81,10 @@ class ScanTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: ScanReducer.State(),
|
||||
reducer: ScanReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.uriParser.isValidURI = { _ in true }
|
||||
) { dependencies in
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.uriParser.isValidURI = { _ in true }
|
||||
}
|
||||
|
||||
store.send(.scan("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")) { state in
|
||||
state.scanStatus = .value("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")
|
||||
|
|
|
@ -34,14 +34,14 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.mnemonic = .mock
|
||||
store.dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
store.dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.mnemonic = .mock
|
||||
dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
}
|
||||
|
||||
// simulate the sending confirmation button to be pressed
|
||||
store.send(.sendConfirmationPressed) { state in
|
||||
|
@ -93,14 +93,14 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: state,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.mnemonic = .mock
|
||||
store.dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
store.dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.mnemonic = .mock
|
||||
dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
}
|
||||
|
||||
// simulate the sending confirmation button to be pressed
|
||||
store.send(.sendConfirmationPressed) { state in
|
||||
|
@ -149,13 +149,13 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
store.dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.mnemonic = .mock
|
||||
store.dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.deriveSpendingKeys = { _, _ in [""] }
|
||||
dependencies.mainQueue = testScheduler.eraseToAnyScheduler()
|
||||
dependencies.mnemonic = .mock
|
||||
dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
}
|
||||
|
||||
// simulate the sending confirmation button to be pressed
|
||||
store.send(.sendConfirmationPressed) { state in
|
||||
|
@ -184,14 +184,14 @@ class SendTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testAddressValidation() throws {
|
||||
func testAddressValidation_Invalid() throws {
|
||||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.isValidZcashAddress = { _ in false }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.isValidZcashAddress = { _ in false }
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("3HRG769ii3HDSJV5vNknQPzXqtL2mTSGnr")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "3HRG769ii3HDSJV5vNknQPzXqtL2mTSGnr"
|
||||
|
@ -204,8 +204,16 @@ class SendTests: XCTestCase {
|
|||
"Send Tests: `testAddressValidation` is expected to be true but it's \(state.isInvalidAddressFormat)"
|
||||
)
|
||||
}
|
||||
|
||||
store.dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
}
|
||||
|
||||
func testAddressValidation_Valid() throws {
|
||||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po"
|
||||
|
@ -224,9 +232,9 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter = .noOp
|
||||
) {
|
||||
$0.numberFormatter = .noOp
|
||||
}
|
||||
|
||||
// Checks the computed property `isInvalidAmountFormat` which controls the error message to be shown on the screen
|
||||
// With empty input it must be false
|
||||
|
@ -239,9 +247,9 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
) {
|
||||
$0.derivationTool = .noOp
|
||||
}
|
||||
|
||||
// Checks the computed property `isInvalidAddressFormat` which controls the error message to be shown on the screen
|
||||
// With empty input it must be false
|
||||
|
@ -257,7 +265,7 @@ class SendTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testFundsSufficiency() throws {
|
||||
func testFundsSufficiency_SufficientAmount() throws {
|
||||
let sendState = SendFlowReducer.State(
|
||||
addMemoState: true,
|
||||
memoState: .placeholder,
|
||||
|
@ -277,10 +285,10 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter = .noOp
|
||||
store.dependencies.numberFormatter.number = { _ in NSNumber(0.00501299) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter = .noOp
|
||||
dependencies.numberFormatter.number = { _ in NSNumber(0.00501299) }
|
||||
}
|
||||
|
||||
store.send(.transactionAmountInput(.textField(.set("0.00501299")))) { state in
|
||||
state.transactionAmountInputState.textFieldState.text = "0.00501299"
|
||||
|
@ -294,8 +302,32 @@ class SendTests: XCTestCase {
|
|||
store.receive(.transactionAmountInput(.updateAmount)) { state in
|
||||
state.transactionAmountInputState.amount = 501_299
|
||||
}
|
||||
|
||||
store.dependencies.numberFormatter.number = { _ in NSNumber(0.00501301) }
|
||||
}
|
||||
|
||||
func testFundsSufficiency_InsufficientAmount() throws {
|
||||
let sendState = SendFlowReducer.State(
|
||||
addMemoState: true,
|
||||
memoState: .placeholder,
|
||||
transactionAddressInputState: .placeholder,
|
||||
transactionAmountInputState:
|
||||
TransactionAmountTextFieldReducer.State(
|
||||
currencySelectionState: CurrencySelectionReducer.State(),
|
||||
maxValue: 501_300,
|
||||
textFieldState:
|
||||
TCATextFieldReducer.State(
|
||||
validationType: .customFloatingPoint(usNumberFormatter),
|
||||
text: ""
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter = .noOp
|
||||
dependencies.numberFormatter.number = { _ in NSNumber(0.00501301) }
|
||||
}
|
||||
|
||||
store.send(.transactionAmountInput(.textField(.set("0.00501301")))) { state in
|
||||
state.transactionAmountInputState.textFieldState.text = "0.00501301"
|
||||
|
@ -351,10 +383,10 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po"
|
||||
|
@ -389,10 +421,10 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po"
|
||||
|
@ -427,9 +459,9 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
) {
|
||||
$0.derivationTool = .noOp
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("3HRG769ii3HDSJV5vNknQPzXqtL2mTSGnr")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "3HRG769ii3HDSJV5vNknQPzXqtL2mTSGnr"
|
||||
|
@ -464,10 +496,10 @@ class SendTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: sendState,
|
||||
reducer: SendFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.derivationTool = .noOp
|
||||
store.dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
) { dependencies in
|
||||
dependencies.derivationTool = .noOp
|
||||
dependencies.derivationTool.isValidZcashAddress = { _ in true }
|
||||
}
|
||||
|
||||
store.send(.transactionAddressInput(.textField(.set("tmGh6ttAnQRJra81moqYcedFadW9XtUT5Eq")))) { state in
|
||||
state.transactionAddressInputState.textFieldState.text = "tmGh6ttAnQRJra81moqYcedFadW9XtUT5Eq"
|
||||
|
|
|
@ -34,10 +34,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
)
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.setMax) { state in
|
||||
state.textFieldState.text = "0.00501301"
|
||||
|
@ -85,10 +85,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.currencySelection(.swapCurrencyType)) { state in
|
||||
state.textFieldState.text = "1,000"
|
||||
|
@ -116,10 +116,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.currencySelection(.swapCurrencyType)) { state in
|
||||
state.textFieldState.text = "25,000,000"
|
||||
|
@ -147,10 +147,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.currencySelection(.swapCurrencyType)) { state in
|
||||
state.textFieldState.text = "1"
|
||||
|
@ -179,10 +179,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.textField(.set("1 000"))) { state in
|
||||
state.textFieldState.text = "1 000"
|
||||
|
@ -220,10 +220,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.setMax) { state in
|
||||
state.textFieldState.text = "2"
|
||||
|
@ -251,10 +251,10 @@ class TransactionAmountTextFieldTests: XCTestCase {
|
|||
zecPrice: 1000.0
|
||||
),
|
||||
reducer: TransactionAmountTextFieldReducer()
|
||||
)
|
||||
|
||||
store.dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
store.dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
) { dependencies in
|
||||
dependencies.numberFormatter.string = { self.usNumberFormatter.string(from: $0) }
|
||||
dependencies.numberFormatter.number = { self.usNumberFormatter.number(from: $0) }
|
||||
}
|
||||
|
||||
store.send(.setMax) { state in
|
||||
state.textFieldState.text = "2,000"
|
||||
|
|
|
@ -47,12 +47,12 @@ class SettingsTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: SettingsReducer.State(phraseDisplayState: RecoveryPhraseDisplayReducer.State(phrase: nil)),
|
||||
reducer: SettingsReducer()
|
||||
)
|
||||
|
||||
store.dependencies.localAuthentication = .mockAuthenticationSucceeded
|
||||
store.dependencies.mnemonic = .noOp
|
||||
store.dependencies.mnemonic.asWords = { _ in mnemonic.components(separatedBy: " ") }
|
||||
store.dependencies.walletStorage = mockedWalletStorage
|
||||
) { dependencies in
|
||||
dependencies.localAuthentication = .mockAuthenticationSucceeded
|
||||
dependencies.mnemonic = .noOp
|
||||
dependencies.mnemonic.asWords = { _ in mnemonic.components(separatedBy: " ") }
|
||||
dependencies.walletStorage = mockedWalletStorage
|
||||
}
|
||||
|
||||
_ = await store.send(.backupWalletAccessRequest)
|
||||
|
||||
|
@ -68,9 +68,9 @@ class SettingsTests: XCTestCase {
|
|||
let store = TestStore(
|
||||
initialState: .placeholder,
|
||||
reducer: SettingsReducer()
|
||||
)
|
||||
|
||||
store.dependencies.localAuthentication = .mockAuthenticationFailed
|
||||
) {
|
||||
$0.localAuthentication = .mockAuthenticationFailed
|
||||
}
|
||||
|
||||
_ = await store.send(.backupWalletAccessRequest)
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ class WalletEventsTests: XCTestCase {
|
|||
walletEvents: identifiedWalletEvents
|
||||
),
|
||||
reducer: WalletEventsFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
store.dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
) { dependencies in
|
||||
dependencies.mainQueue = Self.testScheduler.eraseToAnyScheduler()
|
||||
dependencies.sdkSynchronizer = SDKSynchronizerDependency.mock
|
||||
}
|
||||
|
||||
store.send(.synchronizerStateChanged(.synced))
|
||||
|
||||
|
@ -99,6 +99,8 @@ class WalletEventsTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testCopyToPasteboard() throws {
|
||||
let testPasteboard = PasteboardClient.testPasteboard
|
||||
|
||||
let store = TestStore(
|
||||
initialState: WalletEventsFlowReducer.State(
|
||||
route: .latest,
|
||||
|
@ -106,15 +108,15 @@ class WalletEventsTests: XCTestCase {
|
|||
walletEvents: []
|
||||
),
|
||||
reducer: WalletEventsFlowReducer()
|
||||
)
|
||||
|
||||
store.dependencies.pasteboard = .testPasteboard
|
||||
) {
|
||||
$0.pasteboard = testPasteboard
|
||||
}
|
||||
|
||||
let testText = "test text"
|
||||
store.send(.copyToPastboard(testText))
|
||||
|
||||
XCTAssertEqual(
|
||||
store.dependencies.pasteboard.getString(),
|
||||
testPasteboard.getString(),
|
||||
testText,
|
||||
"WalletEvetns: `testCopyToPasteboard` is expected to match the input `\(testText)`"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue