Skip to content

Commit f7c786d

Browse files
committed
wip
1 parent af32a8d commit f7c786d

File tree

5 files changed

+219
-208
lines changed

5 files changed

+219
-208
lines changed

Examples/TicTacToe/tic-tac-toe/Tests/AppCoreTests/AppCoreTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ final class AppCoreTests: XCTestCase {
1717
}
1818
}
1919

20-
await store.send(.login(.emailChanged("[email protected]"))) {
20+
await store.send(.login(.view(.set(\.$email, "[email protected]")))) {
2121
try (/TicTacToe.State.login).modify(&$0) {
2222
$0.email = "[email protected]"
2323
}
2424
}
25-
await store.send(.login(.passwordChanged("bl0bbl0b"))) {
25+
await store.send(.login(.view(.set(\.$password, "bl0bbl0b")))) {
2626
try (/TicTacToe.State.login).modify(&$0) {
2727
$0.password = "bl0bbl0b"
2828
$0.isFormValid = true
2929
}
3030
}
31-
await store.send(.login(.loginButtonTapped)) {
31+
await store.send(.login(.view(.loginButtonTapped))) {
3232
try (/TicTacToe.State.login).modify(&$0) {
3333
$0.isLoginRequestInFlight = true
3434
}
@@ -64,20 +64,20 @@ final class AppCoreTests: XCTestCase {
6464
}
6565
}
6666

67-
await store.send(.login(.emailChanged("[email protected]"))) {
67+
await store.send(.login(.view(.set(\.$email, "[email protected]")))) {
6868
try (/TicTacToe.State.login).modify(&$0) {
6969
$0.email = "[email protected]"
7070
}
7171
}
7272

73-
await store.send(.login(.passwordChanged("bl0bbl0b"))) {
73+
await store.send(.login(.view(.set(\.$password, "bl0bbl0b")))) {
7474
try (/TicTacToe.State.login).modify(&$0) {
7575
$0.password = "bl0bbl0b"
7676
$0.isFormValid = true
7777
}
7878
}
7979

80-
await store.send(.login(.loginButtonTapped)) {
80+
await store.send(.login(.view(.loginButtonTapped))) {
8181
try (/TicTacToe.State.login).modify(&$0) {
8282
$0.isLoginRequestInFlight = true
8383
}
@@ -93,14 +93,14 @@ final class AppCoreTests: XCTestCase {
9393
}
9494
}
9595

96-
await store.send(.login(.twoFactor(.presented(.codeChanged("1234"))))) {
96+
await store.send(.login(.twoFactor(.presented(.view(.set(\.$code, "1234")))))) {
9797
try (/TicTacToe.State.login).modify(&$0) {
9898
$0.twoFactor?.code = "1234"
9999
$0.twoFactor?.isFormValid = true
100100
}
101101
}
102102

103-
await store.send(.login(.twoFactor(.presented(.submitButtonTapped)))) {
103+
await store.send(.login(.twoFactor(.presented(.view(.submitButtonTapped))))) {
104104
try (/TicTacToe.State.login).modify(&$0) {
105105
$0.twoFactor?.isTwoFactorRequestInFlight = true
106106
}

Examples/TicTacToe/tic-tac-toe/Tests/LoginCoreTests/LoginCoreTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ final class LoginCoreTests: XCTestCase {
1818
}
1919
}
2020

21-
await store.send(.emailChanged("[email protected]")) {
21+
await store.send(.view(.set(\.$email, "[email protected]"))) {
2222
$0.email = "[email protected]"
2323
}
24-
await store.send(.passwordChanged("password")) {
24+
await store.send(.view(.set(\.$password, "password"))) {
2525
$0.password = "password"
2626
$0.isFormValid = true
2727
}
28-
let twoFactorPresentationTask = await store.send(.loginButtonTapped) {
28+
let twoFactorPresentationTask = await store.send(.view(.loginButtonTapped)) {
2929
$0.isLoginRequestInFlight = true
3030
}
3131
await store.receive(
@@ -36,11 +36,11 @@ final class LoginCoreTests: XCTestCase {
3636
$0.isLoginRequestInFlight = false
3737
$0.twoFactor = TwoFactor.State(token: "deadbeefdeadbeef")
3838
}
39-
await store.send(.twoFactor(.presented(.codeChanged("1234")))) {
39+
await store.send(.twoFactor(.presented(.view(.set(\.$code, "1234"))))) {
4040
$0.twoFactor?.code = "1234"
4141
$0.twoFactor?.isFormValid = true
4242
}
43-
await store.send(.twoFactor(.presented(.submitButtonTapped))) {
43+
await store.send(.twoFactor(.presented(.view(.submitButtonTapped)))) {
4444
$0.twoFactor?.isTwoFactorRequestInFlight = true
4545
}
4646
await store.receive(
@@ -70,14 +70,14 @@ final class LoginCoreTests: XCTestCase {
7070
}
7171
}
7272

73-
await store.send(.emailChanged("[email protected]")) {
73+
await store.send(.view(.set(\.$email, "[email protected]"))) {
7474
$0.email = "[email protected]"
7575
}
76-
await store.send(.passwordChanged("password")) {
76+
await store.send(.view(.set(\.$password, "password"))) {
7777
$0.password = "password"
7878
$0.isFormValid = true
7979
}
80-
await store.send(.loginButtonTapped) {
80+
await store.send(.view(.loginButtonTapped)) {
8181
$0.isLoginRequestInFlight = true
8282
}
8383
await store.receive(
@@ -88,11 +88,11 @@ final class LoginCoreTests: XCTestCase {
8888
$0.isLoginRequestInFlight = false
8989
$0.twoFactor = TwoFactor.State(token: "deadbeefdeadbeef")
9090
}
91-
await store.send(.twoFactor(.presented(.codeChanged("1234")))) {
91+
await store.send(.twoFactor(.presented(.view(.set(\.$code, "1234"))))) {
9292
$0.twoFactor?.code = "1234"
9393
$0.twoFactor?.isFormValid = true
9494
}
95-
await store.send(.twoFactor(.presented(.submitButtonTapped))) {
95+
await store.send(.twoFactor(.presented(.view(.submitButtonTapped)))) {
9696
$0.twoFactor?.isTwoFactorRequestInFlight = true
9797
}
9898
await store.send(.twoFactor(.dismiss)) {

Examples/TicTacToe/tic-tac-toe/Tests/LoginSwiftUITests/LoginSwiftUITests.swift

Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
$0.email = "[email protected]"
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-
$0.email = "[email protected]"
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+
// $0.email = "[email protected]"
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+
// $0.email = "[email protected]"
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+
//}

Examples/TicTacToe/tic-tac-toe/Tests/TwoFactorCoreTests/TwoFactorCoreTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ final class TwoFactorCoreTests: XCTestCase {
1414
}
1515
}
1616

17-
await store.send(.codeChanged("1")) {
17+
await store.send(.view(.set(\.$code, "1"))) {
1818
$0.code = "1"
1919
}
20-
await store.send(.codeChanged("12")) {
20+
await store.send(.view(.set(\.$code, "12"))) {
2121
$0.code = "12"
2222
}
23-
await store.send(.codeChanged("123")) {
23+
await store.send(.view(.set(\.$code, "123"))) {
2424
$0.code = "123"
2525
}
26-
await store.send(.codeChanged("1234")) {
26+
await store.send(.view(.set(\.$code, "1234"))) {
2727
$0.code = "1234"
2828
$0.isFormValid = true
2929
}
30-
await store.send(.submitButtonTapped) {
30+
await store.send(.view(.submitButtonTapped)) {
3131
$0.isTwoFactorRequestInFlight = true
3232
}
3333
await store.receive(
@@ -48,11 +48,11 @@ final class TwoFactorCoreTests: XCTestCase {
4848
}
4949
}
5050

51-
await store.send(.codeChanged("1234")) {
51+
await store.send(.view(.set(\.$code, "1234"))) {
5252
$0.code = "1234"
5353
$0.isFormValid = true
5454
}
55-
await store.send(.submitButtonTapped) {
55+
await store.send(.view(.submitButtonTapped)) {
5656
$0.isTwoFactorRequestInFlight = true
5757
}
5858
await store.receive(.twoFactorResponse(.failure(AuthenticationError.invalidTwoFactor))) {

0 commit comments

Comments
 (0)