Skip to content

Commit

Permalink
some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Mar 21, 2024
1 parent aeb92d3 commit b7bc4f4
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@ import XCTest
final class AppCoreTests: XCTestCase {
@MainActor
func testIntegration() async {
let store = TestStore(TicTacToe()) {
TicTacToe.body
} withDependencies: {
let middleware = TestMiddleware()
let store = Store(TicTacToe.login()).transformDI {
$0.authenticationClient.login = { @Sendable _, _ in
AuthenticationResponse(token: "deadbeef", twoFactorRequired: false)
}
}
.middleware(middleware)

await store.send(\.login.view.binding.email, "[email protected]") {
$0.login?.email = "[email protected]"
}
await store.send(\.login.view.binding.password, "bl0bbl0b") {
$0.login?.password = "bl0bbl0b"
$0.login?.isFormValid = true
}
await store.send(\.login.view.loginButtonTapped) {
$0.login?.isLoginRequestInFlight = true
}
await store.receive(\.login.loginResponse.success) {
$0 = .newGame(NewGame.State())
}
store.state.login.email = "[email protected]"
XCTAssertEqual(store.state.login.email, "[email protected]")
store.state.login.password = "bl0bbl0b"
XCTAssertEqual(store.state.login.password, "bl0bbl0b")
XCTAssertTrue(store.state.login.isFormValid)

await store.login.loginButtonTapped()
// XCTAssertTrue(store.login.isLoginRequestInFlight)
XCTAssertEqual(store.state.selected, .newGame)
store.state.newGame.oPlayerName = "Blob Sr."
await store.send(\.newGame.binding.oPlayerName, "Blob Sr.") {
$0.newGame?.oPlayerName = "Blob Sr."
}
Expand Down
Loading

0 comments on commit b7bc4f4

Please sign in to comment.