blockchainethereumblockchain-walleterc20erc721walletxdaidappdecentralizederc1155erc875iosswifttokens
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.7 KiB
87 lines
3.7 KiB
// Copyright SIX DAY LLC. All rights reserved.
|
|
|
|
import XCTest
|
|
@testable import AlphaWallet
|
|
import Combine
|
|
|
|
extension WalletConnectCoordinator {
|
|
|
|
static func fake() -> WalletConnectCoordinator {
|
|
let keystore = FakeEtherKeystore()
|
|
var sessions = ServerDictionary<WalletSession>()
|
|
let session = WalletSession.make()
|
|
sessions[session.server] = session
|
|
let sessionsSubject = CurrentValueSubject<ServerDictionary<WalletSession>, Never>(sessions)
|
|
|
|
return WalletConnectCoordinator(keystore: keystore, navigationController: .init(), analyticsCoordinator: FakeAnalyticsService(), config: .make(), sessionsSubject: sessionsSubject)
|
|
}
|
|
}
|
|
|
|
class ConfigTests: XCTestCase {
|
|
|
|
//This is still used by Dapp browser
|
|
func testChangeChainID() {
|
|
let testDefaults = UserDefaults.test
|
|
XCTAssertEqual(1, Config.getChainId(defaults: testDefaults))
|
|
Config.setChainId(RPCServer.ropsten.chainID, defaults: testDefaults)
|
|
XCTAssertEqual(RPCServer.ropsten.chainID, Config.getChainId(defaults: testDefaults))
|
|
}
|
|
|
|
func testSwitchLocale() {
|
|
var sessions = ServerDictionary<WalletSession>()
|
|
sessions[.main] = WalletSession.make()
|
|
|
|
let config: Config = .make()
|
|
Config.setLocale(AppLocale.english)
|
|
let coinTickersFetcher = FakeCoinTickersFetcher()
|
|
let tokenActionsService = FakeSwapTokenService()
|
|
let tokensDataStore = FakeTokensDataStore()
|
|
|
|
let coordinator_1 = TokensCoordinator(
|
|
navigationController: FakeNavigationController(),
|
|
sessions: sessions,
|
|
keystore: FakeKeystore(),
|
|
config: config,
|
|
tokensDataStore: tokensDataStore,
|
|
assetDefinitionStore: AssetDefinitionStore(),
|
|
eventsDataStore: FakeEventsDataStore(),
|
|
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),
|
|
analyticsCoordinator: FakeAnalyticsService(),
|
|
tokenActionsService: tokenActionsService,
|
|
walletConnectCoordinator: .fake(),
|
|
coinTickersFetcher: coinTickersFetcher,
|
|
activitiesService: FakeActivitiesService(),
|
|
walletBalanceService: FakeMultiWalletBalanceService()
|
|
)
|
|
|
|
coordinator_1.start()
|
|
coordinator_1.tokensViewController.viewWillAppear(false)
|
|
XCTAssertEqual(coordinator_1.tokensViewController.title, "Wallet")
|
|
|
|
Config.setLocale(AppLocale.simplifiedChinese)
|
|
|
|
let coordinator_2 = TokensCoordinator(
|
|
navigationController: FakeNavigationController(),
|
|
sessions: sessions,
|
|
keystore: FakeKeystore(),
|
|
config: config,
|
|
tokensDataStore: tokensDataStore,
|
|
assetDefinitionStore: AssetDefinitionStore(),
|
|
eventsDataStore: FakeEventsDataStore(),
|
|
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),
|
|
analyticsCoordinator: FakeAnalyticsService(),
|
|
tokenActionsService: tokenActionsService,
|
|
walletConnectCoordinator: .fake(),
|
|
coinTickersFetcher: coinTickersFetcher,
|
|
activitiesService: FakeActivitiesService(),
|
|
walletBalanceService: FakeMultiWalletBalanceService()
|
|
)
|
|
|
|
coordinator_2.start()
|
|
coordinator_2.tokensViewController.viewWillAppear(false)
|
|
XCTAssertEqual(coordinator_2.tokensViewController.title, "我的钱包")
|
|
|
|
//Must change this back to system, otherwise other tests will break either immediately or the next run
|
|
Config.setLocale(AppLocale.system)
|
|
}
|
|
}
|
|
|