@@ -5,107 +5,107 @@ import XCTest
55
66@testable import LoginSwiftUI
77
8- @MainActor
9- final class LoginSwiftUITests : XCTestCase {
10- func testFlow_Success( ) async {
11- let store = TestStore ( initialState: Login . State ( ) ) {
12- Login ( )
13- } observe: {
14- LoginView . ViewState ( state: $0)
15- } send: {
16- Login . Action ( action: $0)
17- } withDependencies: {
18- $0. authenticationClient. login = { _ in
19- AuthenticationResponse ( token: " deadbeefdeadbeef " , twoFactorRequired: false )
20- }
21- }
22-
23- await store
. send ( . emailChanged
( " [email protected] " ) ) { 24- 25- }
26- await store. send ( . passwordChanged( " password " ) ) {
27- $0. password = " password "
28- $0. isLoginButtonDisabled = false
29- }
30- await store. send ( . loginButtonTapped) {
31- $0. isActivityIndicatorVisible = true
32- $0. isFormDisabled = true
33- }
34- await store. receive (
35- . loginResponse(
36- . success( AuthenticationResponse ( token: " deadbeefdeadbeef " , twoFactorRequired: false ) )
37- )
38- ) {
39- $0. isActivityIndicatorVisible = false
40- $0. isFormDisabled = false
41- }
42- }
43-
44- func testFlow_Success_TwoFactor( ) async {
45- let store = TestStore ( initialState: Login . State ( ) ) {
46- Login ( )
47- } observe: {
48- LoginView . ViewState ( state: $0)
49- } send: {
50- Login . Action ( action: $0)
51- } withDependencies: {
52- $0. authenticationClient. login = { _ in
53- AuthenticationResponse ( token: " deadbeefdeadbeef " , twoFactorRequired: true )
54- }
55- }
56-
57- await store
. send ( . emailChanged
( " [email protected] " ) ) { 58- 59- }
60- await store. send ( . passwordChanged( " password " ) ) {
61- $0. password = " password "
62- $0. isLoginButtonDisabled = false
63- }
64- let twoFactorPresentationTask = await store. send ( . loginButtonTapped) {
65- $0. isActivityIndicatorVisible = true
66- $0. isFormDisabled = true
67- }
68- await store. receive (
69- . loginResponse(
70- . success( AuthenticationResponse ( token: " deadbeefdeadbeef " , twoFactorRequired: true ) )
71- )
72- ) {
73- $0. isActivityIndicatorVisible = false
74- $0. isFormDisabled = false
75- }
76- await twoFactorPresentationTask. cancel ( )
77- }
78-
79- func testFlow_Failure( ) async {
80- let store = TestStore ( initialState: Login . State ( ) ) {
81- Login ( )
82- } observe: {
83- LoginView . ViewState ( state: $0)
84- } send: {
85- Login . Action ( action: $0)
86- } withDependencies: {
87- $0. authenticationClient. login = { _ in
88- throw AuthenticationError . invalidUserPassword
89- }
90- }
91-
92- await store. send ( . emailChanged( " blob " ) ) {
93- $0. email = " blob "
94- }
95- await store. send ( . passwordChanged( " password " ) ) {
96- $0. password = " password "
97- $0. isLoginButtonDisabled = false
98- }
99- await store. send ( . loginButtonTapped) {
100- $0. isActivityIndicatorVisible = true
101- $0. isFormDisabled = true
102- }
103- await store. receive ( . loginResponse( . failure( AuthenticationError . invalidUserPassword) ) ) {
104- $0. alert = AlertState {
105- TextState ( AuthenticationError . invalidUserPassword. localizedDescription)
106- }
107- $0. isActivityIndicatorVisible = false
108- $0. isFormDisabled = false
109- }
110- }
111- }
8+ // @MainActor
9+ // final class LoginSwiftUITests: XCTestCase {
10+ // func testFlow_Success() async {
11+ // let store = TestStore(initialState: Login.State()) {
12+ // Login()
13+ // } observe: {
14+ // LoginView.ViewState(state: $0)
15+ // } send: {
16+ // Login.Action(action: $0)
17+ // } withDependencies: {
18+ // $0.authenticationClient.login = { _ in
19+ // AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: false)
20+ // }
21+ // }
22+ //
23+ // await store.send(.emailChanged("
[email protected] ")) {
24+ 25+ // }
26+ // await store.send(.passwordChanged("password")) {
27+ // $0.password = "password"
28+ // $0.isLoginButtonDisabled = false
29+ // }
30+ // await store.send(.loginButtonTapped) {
31+ // $0.isActivityIndicatorVisible = true
32+ // $0.isFormDisabled = true
33+ // }
34+ // await store.receive(
35+ // .loginResponse(
36+ // .success(AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: false))
37+ // )
38+ // ) {
39+ // $0.isActivityIndicatorVisible = false
40+ // $0.isFormDisabled = false
41+ // }
42+ // }
43+ //
44+ // func testFlow_Success_TwoFactor() async {
45+ // let store = TestStore(initialState: Login.State()) {
46+ // Login()
47+ // } observe: {
48+ // LoginView.ViewState(state: $0)
49+ // } send: {
50+ // Login.Action(action: $0)
51+ // } withDependencies: {
52+ // $0.authenticationClient.login = { _ in
53+ // AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: true)
54+ // }
55+ // }
56+ //
57+ // await store.send(.emailChanged("
[email protected] ")) {
58+ 59+ // }
60+ // await store.send(.passwordChanged("password")) {
61+ // $0.password = "password"
62+ // $0.isLoginButtonDisabled = false
63+ // }
64+ // let twoFactorPresentationTask = await store.send(.loginButtonTapped) {
65+ // $0.isActivityIndicatorVisible = true
66+ // $0.isFormDisabled = true
67+ // }
68+ // await store.receive(
69+ // .loginResponse(
70+ // .success(AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: true))
71+ // )
72+ // ) {
73+ // $0.isActivityIndicatorVisible = false
74+ // $0.isFormDisabled = false
75+ // }
76+ // await twoFactorPresentationTask.cancel()
77+ // }
78+ //
79+ // func testFlow_Failure() async {
80+ // let store = TestStore(initialState: Login.State()) {
81+ // Login()
82+ // } observe: {
83+ // LoginView.ViewState(state: $0)
84+ // } send: {
85+ // Login.Action(action: $0)
86+ // } withDependencies: {
87+ // $0.authenticationClient.login = { _ in
88+ // throw AuthenticationError.invalidUserPassword
89+ // }
90+ // }
91+ //
92+ // await store.send(.emailChanged("blob")) {
93+ // $0.email = "blob"
94+ // }
95+ // await store.send(.passwordChanged("password")) {
96+ // $0.password = "password"
97+ // $0.isLoginButtonDisabled = false
98+ // }
99+ // await store.send(.loginButtonTapped) {
100+ // $0.isActivityIndicatorVisible = true
101+ // $0.isFormDisabled = true
102+ // }
103+ // await store.receive(.loginResponse(.failure(AuthenticationError.invalidUserPassword))) {
104+ // $0.alert = AlertState {
105+ // TextState(AuthenticationError.invalidUserPassword.localizedDescription)
106+ // }
107+ // $0.isActivityIndicatorVisible = false
108+ // $0.isFormDisabled = false
109+ // }
110+ // }
111+ // }
0 commit comments