Skip to content

Commit 00d0338

Browse files
committed
feat: added Single/Tab Navigator Mock
1 parent 918a1d4 commit 00d0338

3 files changed

Lines changed: 378 additions & 8 deletions

File tree

Examples/LinkNavigator-Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import Foundation
2+
import UIKit
3+
4+
public final class SingleLinkNavigatorMock {
5+
6+
public var value: Value
7+
public var event: Event
8+
9+
public init(value: Value = .init(), event: Event = .init()) {
10+
self.value = value
11+
self.event = event
12+
}
13+
14+
public func resetEvent() {
15+
event = .init()
16+
}
17+
18+
public func resetValue() {
19+
value = .init()
20+
}
21+
22+
public func resetAll() {
23+
resetEvent()
24+
resetValue()
25+
}
26+
27+
}
28+
29+
extension SingleLinkNavigatorMock {
30+
31+
public struct Value: Equatable, Sendable {
32+
public var currentPaths: [String] = []
33+
public var currentRootPaths: [String] = []
34+
public var rangePaths: [String] = []
35+
36+
public init() {}
37+
}
38+
39+
public struct Event: Equatable, Sendable {
40+
public var getCurrentPaths: Int = .zero
41+
public var getCurrentRootPaths: Int = .zero
42+
public var next: Int = .zero
43+
public var rootNext: Int = .zero
44+
public var sheet: Int = .zero
45+
public var fullSheet: Int = .zero
46+
public var customSheet: Int = .zero
47+
public var replace: Int = .zero
48+
public var backOrNext: Int = .zero
49+
public var rootBackOrNext: Int = .zero
50+
public var back: Int = .zero
51+
public var remove: Int = .zero
52+
public var rootRemove: Int = .zero
53+
public var backToLast: Int = .zero
54+
public var close: Int = .zero
55+
public var range: Int = .zero
56+
public var rootReloadLast: Int = .zero
57+
public var alert: Int = .zero
58+
public var send: Int = .zero
59+
public var mainSend: Int = .zero
60+
public var allSend: Int = .zero
61+
public var rootBackToLast: Int = .zero
62+
public var rootSend: Int = .zero
63+
public var allRootSend: Int = .zero
64+
65+
public init() {}
66+
}
67+
}
68+
69+
extension SingleLinkNavigatorMock: LinkNavigatorFindLocationUsable {
70+
public func getCurrentPaths() -> [String] {
71+
event.getCurrentPaths += 1
72+
return value.currentPaths
73+
}
74+
75+
public func getCurrentRootPaths() -> [String] {
76+
event.getCurrentRootPaths += 1
77+
return value.currentRootPaths
78+
}
79+
}
80+
81+
extension SingleLinkNavigatorMock: LinkNavigatorProtocol {
82+
public func rootBackToLast(path: String, isAnimated: Bool) {
83+
event.rootBackToLast += 1
84+
}
85+
86+
public func rootSend(item: LinkItem) {
87+
event.rootSend += 1
88+
}
89+
90+
public func allRootSend(item: LinkItem) {
91+
event.allRootSend += 1
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 backOrNext(linkItem: LinkItem, isAnimated: Bool) {
125+
event.backOrNext += 1
126+
}
127+
128+
public func rootBackOrNext(linkItem: LinkItem, isAnimated: Bool) {
129+
event.rootBackOrNext += 1
130+
}
131+
132+
public func back(isAnimated: Bool) {
133+
event.back += 1
134+
}
135+
136+
public func remove(pathList: [String]) {
137+
event.remove += 1
138+
}
139+
140+
public func rootRemove(pathList: [String]) {
141+
event.rootRemove += 1
142+
}
143+
144+
public func backToLast(path: String, isAnimated: Bool) {
145+
event.backToLast += 1
146+
}
147+
148+
public func close(isAnimated: Bool, completeAction: @escaping () -> Void) {
149+
event.close += 1
150+
}
151+
152+
public func range(path: String) -> [String] {
153+
event.range += 1
154+
return value.rangePaths
155+
}
156+
157+
public func rootReloadLast(items: LinkItem, isAnimated: Bool) {
158+
event.rootReloadLast += 1
159+
}
160+
161+
public func alert(target: NavigationTarget, model: Alert) {
162+
event.rootReloadLast += 1
163+
}
164+
165+
public func send(item: LinkItem) {
166+
event.send += 1
167+
}
168+
169+
public func mainSend(item: LinkItem) {
170+
event.mainSend += 1
171+
}
172+
173+
public func allSend(item: LinkItem) {
174+
event.allSend += 1
175+
}
176+
177+
}
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
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

Comments
 (0)