@@ -34,12 +34,9 @@ class RootTests: XCTestCase {
34
34
35
35
// Ensure there is no modal visible.
36
36
let firstViewModel = root. viewModel ( for: [ ] , at: displayTime)
37
- switch firstViewModel. modal {
38
- case . none:
39
- // This is the expected case
40
- break
41
- default :
37
+ guard case . none = firstViewModel. modal else {
42
38
XCTFail ( " Expected .none, got \( firstViewModel. modal) " )
39
+ return
43
40
}
44
41
45
42
// Show the backup info.
@@ -59,7 +56,7 @@ class RootTests: XCTestCase {
59
56
case . info( let infoViewModel) :
60
57
XCTAssert ( infoViewModel. title == " Backups " )
61
58
default :
62
- XCTFail ( " Expected .Info , got \( secondViewModel. modal) " )
59
+ XCTFail ( " Expected Backups .info , got \( secondViewModel. modal) " )
63
60
}
64
61
65
62
// Hide the backup info.
@@ -75,12 +72,9 @@ class RootTests: XCTestCase {
75
72
76
73
// Ensure the backup info modal no longer visible.
77
74
let thirdViewModel = root. viewModel ( for: [ ] , at: displayTime)
78
- switch thirdViewModel. modal {
79
- case . none:
80
- // This is the expected case
81
- break
82
- default :
75
+ guard case . none = thirdViewModel. modal else {
83
76
XCTFail ( " Expected .none, got \( thirdViewModel. modal) " )
77
+ return
84
78
}
85
79
}
86
80
@@ -89,12 +83,9 @@ class RootTests: XCTestCase {
89
83
90
84
// Ensure there is no modal visible.
91
85
let firstViewModel = root. viewModel ( for: [ ] , at: displayTime)
92
- switch firstViewModel. modal {
93
- case . none:
94
- // This is the expected case
95
- break
96
- default :
86
+ guard case . none = firstViewModel. modal else {
97
87
XCTFail ( " Expected .none, got \( firstViewModel. modal) " )
88
+ return
98
89
}
99
90
100
91
// Show the license info.
@@ -114,7 +105,7 @@ class RootTests: XCTestCase {
114
105
case . info( let infoViewModel) :
115
106
XCTAssert ( infoViewModel. title == " Acknowledgements " )
116
107
default :
117
- XCTFail ( " Expected .Info , got \( secondViewModel. modal) " )
108
+ XCTFail ( " Expected Acknowledgements .info , got \( secondViewModel. modal) " )
118
109
}
119
110
120
111
// Hide the license info.
@@ -130,12 +121,9 @@ class RootTests: XCTestCase {
130
121
131
122
// Ensure the license info modal no longer visible.
132
123
let thirdViewModel = root. viewModel ( for: [ ] , at: displayTime)
133
- switch thirdViewModel. modal {
134
- case . none:
135
- // This is the expected case
136
- break
137
- default :
124
+ guard case . none = thirdViewModel. modal else {
138
125
XCTFail ( " Expected .none, got \( thirdViewModel. modal) " )
126
+ return
139
127
}
140
128
}
141
129
@@ -156,11 +144,9 @@ class RootTests: XCTestCase {
156
144
return
157
145
}
158
146
159
- switch effect {
160
- case . some( . openURL( let effectURL) ) :
161
- XCTAssertEqual ( effectURL, url)
162
- default :
163
- XCTFail ( " Expected .none, got \( String ( describing: effect) ) " )
147
+ guard case . some( . openURL( url) ) = effect else {
148
+ XCTFail ( " Expected .openURL( \( url) ), got \( String ( describing: effect) ) " )
149
+ return
164
150
}
165
151
}
166
152
@@ -170,10 +156,7 @@ class RootTests: XCTestCase {
170
156
let effect = root. update ( event)
171
157
// TODO: check that the component state hasn't changed
172
158
173
- switch effect {
174
- case . some( . showErrorMessage( " Failed to add token. " ) ) :
175
- break
176
- default :
159
+ guard case . some( . showErrorMessage( " Failed to add token. " ) ) = effect else {
177
160
XCTFail ( " Expected .showErrorMessage( \" Failed to add token. \" ), got \( String ( describing: effect) ) " )
178
161
return
179
162
}
0 commit comments