Skip to content

Commit a67f560

Browse files
committed
test(fixes): remove hard dependency on CommonWallet in tests\n\n- Replace CommonWallet-based mocks with app-local WalletCommand* types\n- Update WalletSelectAccountCommandTests to use WalletPresentationCommand\n- Wrap CommonWallet imports in #if canImport(CommonWallet) guards (WestendStub, CrowdloanContributionConfirmTests, ModuleMocks, etc.)\n- Drop unnecessary CommonWallet import in StubBalanceViewModelFactory
Signed-off-by: William Richter <[email protected]>
1 parent 87feb28 commit a67f560

File tree

6 files changed

+28
-111
lines changed

6 files changed

+28
-111
lines changed

fearlessTests/Helper/WestendStub.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import Foundation
22
@testable import fearless
33
import BigInt
44
import IrohaCrypto
5+
#if canImport(CommonWallet)
56
import CommonWallet
7+
#endif
68
import SSFModels
79

810
struct WestendStub {

fearlessTests/Mocks/ModuleMocks.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13720,7 +13720,9 @@ import Cuckoo
1372013720
@testable import fearless
1372113721

1372213722
import BigInt
13723+
#if canImport(CommonWallet)
1372313724
import CommonWallet
13725+
#endif
1372413726
import Foundation
1372513727
import SoraFoundation
1372613728

@@ -47232,7 +47234,9 @@ import Cuckoo
4723247234
@testable import fearless
4723347235

4723447236
import BigInt
47237+
#if canImport(CommonWallet)
4723547238
import CommonWallet
47239+
#endif
4723647240
import SoraFoundation
4723747241

4723847242

@@ -48688,7 +48692,9 @@ import Cuckoo
4868848692
@testable import fearless
4868948693

4869048694
import BigInt
48695+
#if canImport(CommonWallet)
4869148696
import CommonWallet
48697+
#endif
4869248698
import SoraFoundation
4869348699

4869448700

@@ -50297,7 +50303,9 @@ import Cuckoo
5029750303
@testable import fearless
5029850304

5029950305
import BigInt
50306+
#if canImport(CommonWallet)
5030050307
import CommonWallet
50308+
#endif
5030150309
import Foundation
5030250310
import SoraFoundation
5030350311

@@ -58364,7 +58372,9 @@ import SoraFoundation
5836458372
import Cuckoo
5836558373
@testable import fearless
5836658374

58375+
#if canImport(CommonWallet)
5836758376
import CommonWallet
58377+
#endif
5836858378
import Foundation
5836958379
import SoraFoundation
5837058380

@@ -69203,7 +69213,9 @@ import Cuckoo
6920369213
@testable import fearless
6920469214

6920569215
import BigInt
69216+
#if canImport(CommonWallet)
6920669217
import CommonWallet
69218+
#endif
6920769219
import Foundation
6920869220
import SoraFoundation
6920969221

@@ -72816,7 +72828,9 @@ import SoraFoundation
7281672828
import Cuckoo
7281772829
@testable import fearless
7281872830

72831+
#if canImport(CommonWallet)
7281972832
import CommonWallet
72833+
#endif
7282072834

7282172835

7282272836

@@ -73462,4 +73476,3 @@ import CommonWallet
7346273476

7346373477

7346473478

73465-

fearlessTests/Mocks/ViewModel/StubBalanceViewModelFactory.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Foundation
22
import SoraFoundation
3-
import CommonWallet
43
@testable import fearless
54

65
struct StubBalanceViewModelFactory: BalanceViewModelFactoryProtocol {
Lines changed: 9 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,27 @@
11
import Foundation
2-
import CommonWallet
2+
import UIKit
3+
@testable import fearless
34

45
class WalletCommandProtocolMock: WalletCommandProtocol {
56
func execute() throws {}
67
}
7-
8-
class WalletPresentationCommandProtocolMock: WalletCommandProtocolMock, WalletPresentationCommandProtocol {
9-
var presentationStyle: WalletPresentationStyle = .push(hidesBottomBar: true)
10-
var animated: Bool = false
11-
var completionBlock: (() -> Void)?
12-
}
13-
14-
class AssetDetailsCommandProtocolMock: WalletPresentationCommandProtocolMock, AssetDetailsCommadProtocol {
15-
var ignoredWhenSingleAsset: Bool = false
16-
}
17-
18-
class WalletHideCommandProtocolMock: WalletCommandProtocolMock, WalletHideCommandProtocol {
19-
var actionType: WalletHideActionType = .dismiss
20-
var animated: Bool = false
21-
var completionBlock: (() -> Void)?
22-
}
23-
248
final class WalletCommandFactoryProtocolMock: WalletCommandFactoryProtocol {
25-
var sendClosure: ((String?) -> WalletPresentationCommandProtocol)?
26-
var receiverClosure: ((String?) -> WalletPresentationCommandProtocol)?
27-
var assetDetailsClosure: ((String) -> AssetDetailsCommadProtocol)?
28-
var scanReceiverClosure: (() -> WalletPresentationCommandProtocol)?
29-
var withdrawClosure: ((String, String) -> WalletPresentationCommandProtocol)?
30-
var presentationClosure: ((UIViewController) -> WalletPresentationCommandProtocol)?
31-
var hideClosure: ((WalletHideActionType) -> WalletHideCommandProtocol)?
32-
var accountUpdateClosure: (() -> WalletCommandProtocol)?
33-
var languageUpdateClosure: ((WalletLanguage) -> WalletCommandProtocol)?
34-
var transactionClosure: ((AssetTransactionData) -> WalletPresentationCommandProtocol)?
35-
var transferClosure: ((TransferPayload) -> WalletPresentationCommandProtocol)?
36-
37-
func prepareSendCommand(for assetId: String?) -> WalletPresentationCommandProtocol {
38-
if let closure = sendClosure {
39-
return closure(assetId)
40-
} else {
41-
return WalletPresentationCommandProtocolMock()
42-
}
43-
}
9+
var presentationClosure: ((UIViewController) -> WalletPresentationCommand)?
10+
var hideClosure: ((WalletDismissAction) -> WalletPresentationCommand)?
4411

45-
func prepareReceiveCommand(for assetId: String?) -> WalletPresentationCommandProtocol {
46-
if let closure = receiverClosure {
47-
return closure(assetId)
48-
} else {
49-
return WalletPresentationCommandProtocolMock()
50-
}
51-
}
52-
53-
func prepareAssetDetailsCommand(for assetId: String) -> AssetDetailsCommadProtocol {
54-
if let closure = assetDetailsClosure {
55-
return closure(assetId)
56-
} else {
57-
return AssetDetailsCommandProtocolMock()
58-
}
59-
}
60-
61-
func prepareScanReceiverCommand() -> WalletPresentationCommandProtocol {
62-
if let closure = scanReceiverClosure {
63-
return closure()
64-
} else {
65-
return WalletPresentationCommandProtocolMock()
66-
}
67-
}
68-
69-
func prepareWithdrawCommand(for assetId: String, optionId: String)
70-
-> WalletPresentationCommandProtocol {
71-
if let closure = withdrawClosure {
72-
return closure(assetId, optionId)
73-
} else {
74-
return WalletPresentationCommandProtocolMock()
75-
}
76-
}
77-
78-
func preparePresentationCommand(for controller: UIViewController)
79-
-> WalletPresentationCommandProtocol {
12+
func preparePresentationCommand(for controller: UIViewController) -> WalletPresentationCommand {
8013
if let closure = presentationClosure {
8114
return closure(controller)
8215
} else {
83-
return WalletPresentationCommandProtocolMock()
16+
return WalletPresentationCommand(presentingController: controller)
8417
}
8518
}
8619

87-
func prepareHideCommand(with actionType: WalletHideActionType) -> WalletHideCommandProtocol {
20+
func prepareHideCommand(with action: WalletDismissAction) -> WalletPresentationCommand {
8821
if let closure = hideClosure {
89-
return closure(actionType)
90-
} else {
91-
return WalletHideCommandProtocolMock()
92-
}
93-
}
94-
95-
func prepareAccountUpdateCommand() -> WalletCommandProtocol {
96-
if let closure = accountUpdateClosure {
97-
return closure()
98-
} else {
99-
return WalletCommandProtocolMock()
100-
}
101-
}
102-
103-
func prepareLanguageSwitchCommand(with newLanguage: WalletLanguage) -> WalletCommandProtocol {
104-
if let closure = languageUpdateClosure {
105-
return closure(newLanguage)
106-
} else {
107-
return WalletCommandProtocolMock()
108-
}
109-
}
110-
111-
func prepareTransactionDetailsCommand(with transaction: AssetTransactionData) -> WalletPresentationCommandProtocol {
112-
if let closure = transactionClosure {
113-
return closure(transaction)
114-
} else {
115-
return WalletPresentationCommandProtocolMock()
116-
}
117-
}
118-
119-
func prepareTransfer(with payload: TransferPayload) -> WalletPresentationCommandProtocol {
120-
if let closure = transferClosure {
121-
return closure(payload)
22+
return closure(action)
12223
} else {
123-
return WalletPresentationCommandProtocolMock()
24+
return WalletPresentationCommand()
12425
}
12526
}
12627
}

fearlessTests/Modules/Crowdloan/CrowdloanContributionConfirm/CrowdloanContributionConfirmTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import XCTest
22
@testable import fearless
33
import SoraKeystore
4+
#if canImport(CommonWallet)
45
import CommonWallet
6+
#endif
57
import RobinHood
68
import SoraFoundation
79
import SSFUtils

fearlessTests/Modules/Wallet/Commands/WalletSelectAccountCommandTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class WalletSelectAccountCommandTests: XCTestCase {
2020
commandFactory.presentationClosure = { _ in
2121
completionExpectation.fulfill()
2222

23-
return WalletPresentationCommandProtocolMock()
23+
return WalletPresentationCommand()
2424
}
2525

2626
try command.execute()

0 commit comments

Comments
 (0)