|
| 1 | +import Foundation |
| 2 | +import UIKit |
| 3 | + |
| 4 | +// MARK: - TabLinkNavigatorMock |
| 5 | + |
| 6 | +public final class TabLinkNavigatorMock { |
| 7 | + |
| 8 | + public var value: Value |
| 9 | + public var event: Event |
| 10 | + |
| 11 | + public init( |
| 12 | + value: Value = .init(), |
| 13 | + event: Event = .init()) |
| 14 | + { |
| 15 | + self.value = value |
| 16 | + self.event = event |
| 17 | + } |
| 18 | + |
| 19 | + public func resetEvent() { |
| 20 | + event = .init() |
| 21 | + } |
| 22 | + |
| 23 | + public func resetValue() { |
| 24 | + value = .init() |
| 25 | + } |
| 26 | + |
| 27 | + public func resetAll() { |
| 28 | + resetEvent() |
| 29 | + resetValue() |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +extension TabLinkNavigatorMock { |
| 34 | + public struct Value: Equatable, Sendable { |
| 35 | + public var currentPaths: [String] = [] |
| 36 | + public var currentRootPaths: [String] = [] |
| 37 | + public var rangePaths: [String] = [] |
| 38 | + |
| 39 | + public init() {} |
| 40 | + } |
| 41 | + |
| 42 | + public struct Event: Equatable, Sendable { |
| 43 | + public var next: Int = .zero |
| 44 | + public var rootNext: Int = .zero |
| 45 | + public var sheet: Int = .zero |
| 46 | + public var fullSheet: Int = .zero |
| 47 | + public var customSheet: Int = .zero |
| 48 | + public var replace: Int = .zero |
| 49 | + public var rootReplace: Int = .zero |
| 50 | + public var backOrNext: Int = .zero |
| 51 | + public var rootBackOrNext: Int = .zero |
| 52 | + public var back: Int = .zero |
| 53 | + public var remove: Int = .zero |
| 54 | + public var rootRemove: Int = .zero |
| 55 | + public var backToLast: Int = .zero |
| 56 | + public var rootBackToLast: Int = .zero |
| 57 | + public var close: Int = .zero |
| 58 | + public var reloadLast: Int = .zero |
| 59 | + public var rootReloadLast: Int = .zero |
| 60 | + public var alert: Int = .zero |
| 61 | + public var send: Int = .zero |
| 62 | + public var currentTabSend: Int = .zero |
| 63 | + public var mainSend: Int = .zero |
| 64 | + public var allSend: Int = .zero |
| 65 | + public var currentTabAllSend: Int = .zero |
| 66 | + public var moveTab: Int = .zero |
| 67 | + public var range: Int = .zero |
| 68 | + public var getCurrentRootPaths: Int = .zero |
| 69 | + public var getCurrentPaths: Int = .zero |
| 70 | + |
| 71 | + public init() { |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +// MARK: LinkNavigatorFindLocationUsable, TabLinkNavigatorProtocol |
| 77 | + |
| 78 | +extension TabLinkNavigatorMock: LinkNavigatorFindLocationUsable, TabLinkNavigatorProtocol { |
| 79 | + |
| 80 | + public func alert(model: Alert) { |
| 81 | + event.alert += 1 |
| 82 | + } |
| 83 | + |
| 84 | + public func getCurrentPaths() -> [String] { |
| 85 | + event.getCurrentPaths += 1 |
| 86 | + return value.currentPaths |
| 87 | + } |
| 88 | + |
| 89 | + public func getCurrentRootPaths() -> [String] { |
| 90 | + event.getCurrentRootPaths += 1 |
| 91 | + return value.currentRootPaths |
| 92 | + } |
| 93 | + |
| 94 | + public func next(linkItem _: LinkItem, isAnimated _: Bool) { |
| 95 | + event.next += 1 |
| 96 | + } |
| 97 | + |
| 98 | + public func rootNext(linkItem _: LinkItem, isAnimated _: Bool) { |
| 99 | + event.rootNext += 1 |
| 100 | + } |
| 101 | + |
| 102 | + public func sheet(linkItem _: LinkItem, isAnimated _: Bool) { |
| 103 | + event.sheet += 1 |
| 104 | + } |
| 105 | + |
| 106 | + public func fullSheet(linkItem _: LinkItem, isAnimated _: Bool, prefersLargeTitles _: Bool?) { |
| 107 | + event.fullSheet += 1 |
| 108 | + } |
| 109 | + |
| 110 | + public func customSheet( |
| 111 | + linkItem _: LinkItem, |
| 112 | + isAnimated _: Bool, |
| 113 | + iPhonePresentationStyle _: UIModalPresentationStyle, |
| 114 | + iPadPresentationStyle _: UIModalPresentationStyle, |
| 115 | + prefersLargeTitles _: Bool?) |
| 116 | + { |
| 117 | + event.customSheet += 1 |
| 118 | + } |
| 119 | + |
| 120 | + public func replace(linkItem _: LinkItem, isAnimated _: Bool) { |
| 121 | + event.replace += 1 |
| 122 | + } |
| 123 | + |
| 124 | + public func rootReplace(linkItem _: LinkItem, isAnimated _: Bool, closeAll _: Bool) { |
| 125 | + event.rootReplace += 1 |
| 126 | + } |
| 127 | + |
| 128 | + public func backOrNext(linkItem _: LinkItem, isAnimated _: Bool) { |
| 129 | + event.backOrNext += 1 |
| 130 | + } |
| 131 | + |
| 132 | + public func rootBackOrNext(linkItem _: LinkItem, isAnimated _: Bool) { |
| 133 | + event.rootBackOrNext += 1 |
| 134 | + } |
| 135 | + |
| 136 | + public func back(isAnimated _: Bool) { |
| 137 | + event.back += 1 |
| 138 | + } |
| 139 | + |
| 140 | + public func remove(pathList _: [String]) { |
| 141 | + event.remove += 1 |
| 142 | + } |
| 143 | + |
| 144 | + public func rootRemove(pathList _: [String]) { |
| 145 | + event.rootRemove += 1 |
| 146 | + } |
| 147 | + |
| 148 | + public func backToLast(path _: String, isAnimated _: Bool) { |
| 149 | + event.backToLast += 1 |
| 150 | + } |
| 151 | + |
| 152 | + public func rootBackToLast(path _: String, isAnimated _: Bool) { |
| 153 | + event.rootBackToLast += 1 |
| 154 | + } |
| 155 | + |
| 156 | + public func close(isAnimated _: Bool, completeAction _: @escaping () -> Void) { |
| 157 | + event.close += 1 |
| 158 | + } |
| 159 | + |
| 160 | + public func range(path _: String) -> [String] { |
| 161 | + event.range += 1 |
| 162 | + return value.rangePaths |
| 163 | + } |
| 164 | + |
| 165 | + public func reloadLast(linkItem _: LinkItem, isAnimated _: Bool) { |
| 166 | + event.reloadLast += 1 |
| 167 | + } |
| 168 | + |
| 169 | + public func rootReloadLast(linkItem _: LinkItem, isAnimated _: Bool) { |
| 170 | + event.rootReloadLast += 1 |
| 171 | + } |
| 172 | + |
| 173 | + public func alert(target _: NavigationTarget, model _: Alert) { |
| 174 | + event.alert += 1 |
| 175 | + } |
| 176 | + |
| 177 | + public func send(targetTabPath _: String?, linkItem _: LinkItem) { |
| 178 | + event.send += 1 |
| 179 | + } |
| 180 | + |
| 181 | + public func currentTabSend(linkItem _: LinkItem) { |
| 182 | + event.currentTabSend += 1 |
| 183 | + } |
| 184 | + |
| 185 | + public func mainSend(linkItem _: LinkItem) { |
| 186 | + event.mainSend += 1 |
| 187 | + } |
| 188 | + |
| 189 | + public func allSend(linkItem _: LinkItem) { |
| 190 | + event.allSend += 1 |
| 191 | + } |
| 192 | + |
| 193 | + public func currentTabAllSend(linkItem _: LinkItem) { |
| 194 | + event.currentTabAllSend += 1 |
| 195 | + } |
| 196 | + |
| 197 | + public func moveTab(path _: String) { |
| 198 | + event.moveTab += 1 |
| 199 | + } |
| 200 | + |
| 201 | +} |
0 commit comments