Skip to content
Snippets Groups Projects
Commit 2df7470a authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Update WelcomeFeature

parent ab3a0c0e
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!100Messenger - restore from backup
......@@ -344,7 +344,6 @@ let package = Package(
.target(
name: "WelcomeFeature",
dependencies: [
.target(name: "AppCore"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
.product(name: "XXMessengerClient", package: "elixxir-dapps-sdk-swift"),
],
......
......@@ -90,7 +90,6 @@ extension AppEnvironment {
welcome: {
WelcomeEnvironment(
messenger: messenger,
dbManager: dbManager,
mainQueue: mainQueue,
bgQueue: bgQueue
)
......
import AppCore
import ComposableArchitecture
import SwiftUI
import XXMessengerClient
......@@ -26,18 +25,15 @@ public enum WelcomeAction: Equatable {
public struct WelcomeEnvironment {
public init(
messenger: Messenger,
dbManager: DBManager,
mainQueue: AnySchedulerOf<DispatchQueue>,
bgQueue: AnySchedulerOf<DispatchQueue>
) {
self.messenger = messenger
self.dbManager = dbManager
self.mainQueue = mainQueue
self.bgQueue = bgQueue
}
public var messenger: Messenger
public var dbManager: DBManager
public var mainQueue: AnySchedulerOf<DispatchQueue>
public var bgQueue: AnySchedulerOf<DispatchQueue>
}
......@@ -45,7 +41,6 @@ public struct WelcomeEnvironment {
extension WelcomeEnvironment {
public static let unimplemented = WelcomeEnvironment(
messenger: .unimplemented,
dbManager: .unimplemented,
mainQueue: .unimplemented,
bgQueue: .unimplemented
)
......@@ -59,7 +54,6 @@ public let welcomeReducer = Reducer<WelcomeState, WelcomeAction, WelcomeEnvironm
state.failure = nil
return .future { fulfill in
do {
try env.dbManager.removeDB()
try env.messenger.create()
fulfill(.success(.finished))
}
......
......@@ -5,25 +5,20 @@ import XCTest
@MainActor
final class WelcomeFeatureTests: XCTestCase {
func testNewAccountTapped() {
let mainQueue = DispatchQueue.test
let bgQueue = DispatchQueue.test
var didCreateMessenger = 0
let store = TestStore(
initialState: WelcomeState(),
reducer: welcomeReducer,
environment: .unimplemented
)
let mainQueue = DispatchQueue.test
let bgQueue = DispatchQueue.test
enum Action: Equatable {
case didCreateMessenger
case didRemoveDB
}
var actions: [Action] = []
store.environment.mainQueue = mainQueue.eraseToAnyScheduler()
store.environment.bgQueue = bgQueue.eraseToAnyScheduler()
store.environment.messenger.create.run = { actions.append(.didCreateMessenger) }
store.environment.dbManager.removeDB.run = { actions.append(.didRemoveDB) }
store.environment.messenger.create.run = { didCreateMessenger += 1 }
store.send(.newAccountTapped) {
$0.isCreatingAccount = true
......@@ -32,10 +27,7 @@ final class WelcomeFeatureTests: XCTestCase {
bgQueue.advance()
XCTAssertNoDifference(actions, [
.didRemoveDB,
.didCreateMessenger
])
XCTAssertNoDifference(didCreateMessenger, 1)
mainQueue.advance()
......@@ -60,38 +52,6 @@ final class WelcomeFeatureTests: XCTestCase {
store.environment.mainQueue = mainQueue.eraseToAnyScheduler()
store.environment.bgQueue = bgQueue.eraseToAnyScheduler()
store.environment.messenger.create.run = { throw failure }
store.environment.dbManager.removeDB.run = {}
store.send(.newAccountTapped) {
$0.isCreatingAccount = true
$0.failure = nil
}
bgQueue.advance()
mainQueue.advance()
store.receive(.failed(failure.localizedDescription)) {
$0.isCreatingAccount = false
$0.failure = failure.localizedDescription
}
}
func testNewAccountTappedRemoveDBFailure() {
struct Failure: Error, Equatable {}
let failure = Failure()
let mainQueue = DispatchQueue.test
let bgQueue = DispatchQueue.test
let store = TestStore(
initialState: WelcomeState(),
reducer: welcomeReducer,
environment: .unimplemented
)
store.environment.mainQueue = mainQueue.eraseToAnyScheduler()
store.environment.bgQueue = bgQueue.eraseToAnyScheduler()
store.environment.messenger.create.run = {}
store.environment.dbManager.removeDB.run = { throw failure }
store.send(.newAccountTapped) {
$0.isCreatingAccount = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment