-
Notifications
You must be signed in to change notification settings - Fork 9
/
AccountsClient+Test.swift
76 lines (71 loc) · 3.51 KB
/
AccountsClient+Test.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
extension DependencyValues {
var accountsClient: AccountsClient {
get { self[AccountsClient.self] }
set { self[AccountsClient.self] = newValue }
}
}
// MARK: - AccountsClient + TestDependencyKey
extension AccountsClient: TestDependencyKey {
static let previewValue: Self = .noop
#if DEBUG
static let noop = Self(
getCurrentNetworkID: { .kisharnet },
nextAppearanceID: { _, _ in .sample },
getAccountsOnCurrentNetwork: { throw NoopError() },
getHiddenAccountsOnCurrentNetwork: { throw NoopError() },
accountsOnCurrentNetwork: { AsyncLazySequence([]).eraseToAnyAsyncSequence() },
accountUpdates: { _ in AsyncLazySequence([]).eraseToAnyAsyncSequence() },
getAccountsOnNetwork: { _ in throw NoopError() },
newVirtualAccount: { _ in throw NoopError() },
saveVirtualAccounts: { _ in },
getAccountByAddress: { _ in throw NoopError() },
hasAccountOnNetwork: { _ in false },
updateAccount: { _ in },
debugOnlyDeleteAccount: { _ in }
)
static let testValue = Self(
getCurrentNetworkID: unimplemented("\(Self.self).getCurrentNetworkID"),
nextAppearanceID: unimplemented("\(Self.self).nextAppearanceID"),
getAccountsOnCurrentNetwork: unimplemented("\(Self.self).getAccountsOnCurrentNetwork"),
getHiddenAccountsOnCurrentNetwork: unimplemented("\(Self.self).getHiddenAccountsOnCurrentNetwork"),
accountsOnCurrentNetwork: unimplemented("\(Self.self).accountsOnCurrentNetwork"),
accountUpdates: unimplemented("\(Self.self).accountUpdates"),
getAccountsOnNetwork: unimplemented("\(Self.self).getAccountsOnNetwork"),
newVirtualAccount: unimplemented("\(Self.self).newVirtualAccount"),
saveVirtualAccounts: unimplemented("\(Self.self).saveVirtualAccounts"),
getAccountByAddress: unimplemented("\(Self.self).getAccountByAddress"),
hasAccountOnNetwork: unimplemented("\(Self.self).hasAccountOnNetwork"),
updateAccount: unimplemented("\(Self.self).updateAccount"),
debugOnlyDeleteAccount: unimplemented("\(Self.self).debugOnlyDeleteAccount")
)
#else
static let noop = Self(
getCurrentNetworkID: { .kisharnet },
nextAppearanceID: { _, _ in AppearanceId(value: 0) },
getAccountsOnCurrentNetwork: { throw NoopError() },
getHiddenAccountsOnCurrentNetwork: { throw NoopError() },
accountsOnCurrentNetwork: { AsyncLazySequence([]).eraseToAnyAsyncSequence() },
accountUpdates: { _ in AsyncLazySequence([]).eraseToAnyAsyncSequence() },
getAccountsOnNetwork: { _ in throw NoopError() },
newVirtualAccount: { _ in throw NoopError() },
saveVirtualAccounts: { _ in },
getAccountByAddress: { _ in throw NoopError() },
hasAccountOnNetwork: { _ in false },
updateAccount: { _ in }
)
static let testValue = Self(
getCurrentNetworkID: unimplemented("\(Self.self).getCurrentNetworkID"),
nextAppearanceID: unimplemented("\(Self.self).nextAppearanceID"),
getAccountsOnCurrentNetwork: unimplemented("\(Self.self).getAccountsOnCurrentNetwork"),
getHiddenAccountsOnCurrentNetwork: unimplemented("\(Self.self).getHiddenAccountsOnCurrentNetwork"),
accountsOnCurrentNetwork: unimplemented("\(Self.self).accountsOnCurrentNetwork"),
accountUpdates: unimplemented("\(Self.self).accountUpdates"),
getAccountsOnNetwork: unimplemented("\(Self.self).getAccountsOnNetwork"),
newVirtualAccount: unimplemented("\(Self.self).newVirtualAccount"),
saveVirtualAccounts: unimplemented("\(Self.self).saveVirtualAccounts"),
getAccountByAddress: unimplemented("\(Self.self).getAccountByAddress"),
hasAccountOnNetwork: unimplemented("\(Self.self).hasAccountOnNetwork"),
updateAccount: unimplemented("\(Self.self).updateAccount")
)
#endif
}