@@ -27,15 +27,18 @@ class AuthenticationWorkflowTests: XCTestCase {
27
27
func test_action_back( ) {
28
28
AuthenticationWorkflow
29
29
. Action
30
- . tester ( withState: . twoFactor( intermediateSession: " test " , authenticationError: nil ) )
30
+ . tester (
31
+ workflow: workflow,
32
+ state: . twoFactor( intermediateSession: " session " , authenticationError: nil )
33
+ )
31
34
. send ( action: . back)
32
35
. assert ( state: . emailPassword)
33
36
}
34
37
35
38
func test_action_login( ) {
36
39
AuthenticationWorkflow
37
40
. Action
38
- . tester ( withState : . emailPassword )
41
+ . tester ( workflow : workflow )
39
42
. send ( action
: . login
( email
: " [email protected] " , password
: " password " ) )
40
43
. verifyState { state in
41
44
if case . authorizingEmailPassword( let email, let password) = state {
@@ -50,7 +53,7 @@ class AuthenticationWorkflowTests: XCTestCase {
50
53
func test_action_verifySecondFactor( ) {
51
54
AuthenticationWorkflow
52
55
. Action
53
- . tester ( withState : . emailPassword )
56
+ . tester ( workflow : workflow )
54
57
. send (
55
58
action: . verifySecondFactor(
56
59
intermediateSession: " intermediateSession " ,
@@ -70,7 +73,7 @@ class AuthenticationWorkflowTests: XCTestCase {
70
73
func test_action_authenticationSucceeded( ) {
71
74
AuthenticationWorkflow
72
75
. Action
73
- . tester ( withState : . emailPassword )
76
+ . tester ( workflow : workflow )
74
77
. send (
75
78
action: . authenticationSucceeded(
76
79
response: AuthenticationService . AuthenticationResponse (
@@ -90,7 +93,7 @@ class AuthenticationWorkflowTests: XCTestCase {
90
93
91
94
AuthenticationWorkflow
92
95
. Action
93
- . tester ( withState : . emailPassword )
96
+ . tester ( workflow : workflow )
94
97
. send (
95
98
action: . authenticationSucceeded(
96
99
response: AuthenticationService . AuthenticationResponse (
@@ -112,10 +115,8 @@ class AuthenticationWorkflowTests: XCTestCase {
112
115
AuthenticationWorkflow
113
116
. Action
114
117
. tester (
115
- withState: . authorizingEmailPassword(
116
-
117
- password: " password "
118
- )
118
+ workflow: workflow,
119
+ state
: . authorizingEmailPassword
( email
: " [email protected] " , password
: " password " )
119
120
)
120
121
. send (
121
122
action: . authenticationError( AuthenticationService . AuthenticationError. invalidUserPassword)
@@ -136,10 +137,8 @@ class AuthenticationWorkflowTests: XCTestCase {
136
137
AuthenticationWorkflow
137
138
. Action
138
139
. tester (
139
- withState: . authorizingEmailPassword(
140
-
141
- password: " password "
142
- )
140
+ workflow: workflow,
141
+ state
: . authorizingEmailPassword
( email
: " [email protected] " , password
: " password " )
143
142
)
144
143
. send (
145
144
action: . authenticationError( AuthenticationService . AuthenticationError. invalidUserPassword)
@@ -156,10 +155,8 @@ class AuthenticationWorkflowTests: XCTestCase {
156
155
AuthenticationWorkflow
157
156
. Action
158
157
. tester (
159
- withState: . authorizingTwoFactor(
160
- twoFactorCode: " twoFactorCode " ,
161
- intermediateSession: " intermediateSession "
162
- )
158
+ workflow: workflow,
159
+ state: . authorizingTwoFactor( twoFactorCode: " 123456 " , intermediateSession: " session " )
163
160
)
164
161
. send (
165
162
action: . authenticationError( AuthenticationService . AuthenticationError. invalidTwoFactor)
@@ -178,7 +175,7 @@ class AuthenticationWorkflowTests: XCTestCase {
178
175
// MARK: Render Tests
179
176
180
177
func test_render_initial( ) {
181
- AuthenticationWorkflow ( authenticationService : AuthenticationService ( ) )
178
+ workflow
182
179
. renderTester ( initialState: . emailPassword)
183
180
. expectWorkflow (
184
181
type: LoginWorkflow . self,
@@ -200,7 +197,7 @@ class AuthenticationWorkflowTests: XCTestCase {
200
197
func test_render_AuthorizingEmailPasswordWorker( ) {
201
198
let authenticationService = AuthenticationService ( )
202
199
203
- AuthenticationWorkflow ( authenticationService : authenticationService )
200
+ workflow
204
201
. renderTester (
205
202
initialState: . authorizingEmailPassword(
206
203
@@ -234,7 +231,7 @@ class AuthenticationWorkflowTests: XCTestCase {
234
231
func test_render_authorizingTwoFactorWorker( ) {
235
232
let authenticationService = AuthenticationService ( )
236
233
237
- AuthenticationWorkflow ( authenticationService : authenticationService )
234
+ workflow
238
235
. renderTester (
239
236
initialState: . authorizingTwoFactor(
240
237
twoFactorCode: " twoFactorCode " ,
@@ -268,7 +265,7 @@ class AuthenticationWorkflowTests: XCTestCase {
268
265
func test_render_authenticationErrorAlert( ) {
269
266
let authenticationService = AuthenticationService ( )
270
267
271
- AuthenticationWorkflow ( authenticationService : authenticationService )
268
+ workflow
272
269
. renderTester (
273
270
initialState: . authenticationErrorAlert( error: AuthenticationService . AuthenticationError. invalidUserPassword)
274
271
)
@@ -288,3 +285,7 @@ class AuthenticationWorkflowTests: XCTestCase {
288
285
}
289
286
}
290
287
}
288
+
289
+ private let workflow = AuthenticationWorkflow (
290
+ authenticationService: AuthenticationService ( )
291
+ )
0 commit comments