@@ -27,13 +27,14 @@ import XCTest
27
27
@testable import Authenticator
28
28
29
29
class RootTests : XCTestCase {
30
+ private let defaultDigitGroupSize = 2
30
31
let displayTime = DisplayTime ( date: Date ( ) )
31
32
32
33
func testShowBackupInfo( ) {
33
34
var root = Root ( deviceCanScan: false )
34
35
35
36
// Ensure there is no modal visible.
36
- let ( firstViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
37
+ let ( firstViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
37
38
guard case . none = firstViewModel. modal else {
38
39
XCTFail ( " Expected .none, got \( firstViewModel. modal) " )
39
40
return
@@ -51,12 +52,17 @@ class RootTests: XCTestCase {
51
52
XCTAssertNil ( showEffect)
52
53
53
54
// Ensure the backup info modal is visible.
54
- let ( secondViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
55
+ let ( secondViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
55
56
switch secondViewModel. modal {
56
- case . info( _, . some( let infoViewModel) ) :
57
- XCTAssert ( infoViewModel. title == " Backups " )
57
+ case . menu( let menu) :
58
+ switch menu. child {
59
+ case . info( let infoViewModel) :
60
+ XCTAssert ( infoViewModel. title == " Backups " )
61
+ default :
62
+ XCTFail ( " Expected Backups .info, got \( menu. child) " )
63
+ }
58
64
default :
59
- XCTFail ( " Expected Backups .info , got \( secondViewModel. modal) " )
65
+ XCTFail ( " Expected .menu , got \( secondViewModel. modal) " )
60
66
}
61
67
62
68
// Hide the backup info.
@@ -71,7 +77,7 @@ class RootTests: XCTestCase {
71
77
XCTAssertNil ( hideEffect)
72
78
73
79
// Ensure the backup info modal no longer visible.
74
- let ( thirdViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
80
+ let ( thirdViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
75
81
guard case . none = thirdViewModel. modal else {
76
82
XCTFail ( " Expected .none, got \( thirdViewModel. modal) " )
77
83
return
@@ -82,7 +88,7 @@ class RootTests: XCTestCase {
82
88
var root = Root ( deviceCanScan: false )
83
89
84
90
// Ensure there is no modal visible.
85
- let ( firstViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
91
+ let ( firstViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
86
92
guard case . none = firstViewModel. modal else {
87
93
XCTFail ( " Expected .none, got \( firstViewModel. modal) " )
88
94
return
@@ -100,8 +106,8 @@ class RootTests: XCTestCase {
100
106
XCTAssertNil ( showInfoEffect)
101
107
102
108
// Ensure the info list modal is visible.
103
- let ( nextViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
104
- guard case . info ( _ , . none ) = nextViewModel. modal else {
109
+ let ( nextViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
110
+ guard case . menu ( let menu ) = nextViewModel. modal, case . none = menu . child else {
105
111
XCTFail ( " Expected .info list, got \( nextViewModel. modal) " )
106
112
return
107
113
}
@@ -118,12 +124,17 @@ class RootTests: XCTestCase {
118
124
XCTAssertNil ( showEffect)
119
125
120
126
// Ensure the license info modal is visible.
121
- let ( secondViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
127
+ let ( secondViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
122
128
switch secondViewModel. modal {
123
- case . info( _, . some( let infoViewModel) ) :
124
- XCTAssert ( infoViewModel. title == " Acknowledgements " )
129
+ case . menu( let menu) :
130
+ switch menu. child {
131
+ case . info( let infoViewModel) :
132
+ XCTAssert ( infoViewModel. title == " Acknowledgements " )
133
+ default :
134
+ XCTFail ( " Expected Acknowledgements .info, got \( menu. child) " )
135
+ }
125
136
default :
126
- XCTFail ( " Expected Acknowledgements .info , got \( secondViewModel. modal) " )
137
+ XCTFail ( " Expected .menu , got \( secondViewModel. modal) " )
127
138
}
128
139
129
140
// Hide the license info.
@@ -138,7 +149,7 @@ class RootTests: XCTestCase {
138
149
XCTAssertNil ( hideEffect)
139
150
140
151
// Ensure the license info modal no longer visible.
141
- let ( thirdViewModel, _) = root. viewModel ( with: [ ] , at: displayTime)
152
+ let ( thirdViewModel, _) = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize )
142
153
guard case . none = thirdViewModel. modal else {
143
154
XCTFail ( " Expected .none, got \( thirdViewModel. modal) " )
144
155
return
@@ -194,7 +205,7 @@ class RootTests: XCTestCase {
194
205
var root = Root ( deviceCanScan: false )
195
206
196
207
// Ensure the initial view model has no modal.
197
- guard case . none = root. viewModel ( with: [ ] , at: displayTime) . viewModel. modal else {
208
+ guard case . none = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize ) . viewModel. modal else {
198
209
XCTFail ( " The initial view model should have no modal. " )
199
210
return
200
211
}
@@ -208,7 +219,7 @@ class RootTests: XCTestCase {
208
219
}
209
220
210
221
// Ensure the view model now has a modal entry form.
211
- guard case . entryForm = root. viewModel ( with: [ ] , at: displayTime) . viewModel. modal else {
222
+ guard case . entryForm = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize ) . viewModel. modal else {
212
223
XCTFail ( " The view model should have a modal entry form. " )
213
224
return
214
225
}
@@ -218,7 +229,7 @@ class RootTests: XCTestCase {
218
229
XCTAssertNil ( effect)
219
230
220
231
// Ensure the token entry form hides on success.
221
- guard case . none = root. viewModel ( with: [ ] , at: displayTime) . viewModel. modal else {
232
+ guard case . none = root. viewModel ( with: [ ] , at: displayTime, digitGroupSize : defaultDigitGroupSize ) . viewModel. modal else {
222
233
XCTFail ( " The final view model should have no modal. " )
223
234
return
224
235
}
0 commit comments