-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 53 additions & 4 deletions
57
app-ios/Tests/ContributorFeatureTests/ContributorFeatureTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,66 @@ | ||
import XCTest | ||
import ComposableArchitecture | ||
import Model | ||
@preconcurrency import shared | ||
@testable import ContributorFeature | ||
|
||
final class ContributorFeatureTests: XCTestCase { | ||
|
||
@MainActor | ||
func testExample() async throws { | ||
let store = TestStore(initialState: ContributorReducer.State(text: "HOGE")) { | ||
func testOnAppear() async throws { | ||
let contributors = Contributor.companion.fakes() | ||
let store = TestStore(initialState: ContributorReducer.State()) { | ||
ContributorReducer() | ||
} withDependencies: { | ||
$0.contributorClient.refresh = {} | ||
$0.contributorClient.streamContributors = { | ||
AsyncThrowingStream { | ||
$0.yield(contributors) | ||
$0.finish() | ||
} | ||
} | ||
} | ||
await store.send(.onAppear) { | ||
$0.text = "Contributor Feature" | ||
|
||
await store.send(.onAppear) | ||
await store.receive(\.response) { | ||
$0.contributors = contributors | ||
} | ||
} | ||
|
||
@MainActor | ||
func testOnAppearFail() async throws { | ||
let contributors = Contributor.companion.fakes() | ||
let store = TestStore(initialState: ContributorReducer.State()) { | ||
ContributorReducer() | ||
} withDependencies: { | ||
$0.contributorClient.refresh = { | ||
throw ContributorTestError.fail | ||
} | ||
$0.contributorClient.streamContributors = { | ||
AsyncThrowingStream { | ||
$0.yield(contributors) | ||
$0.finish() | ||
} | ||
} | ||
} | ||
|
||
await store.send(.onAppear) | ||
await store.receive(\.response) | ||
} | ||
|
||
@MainActor | ||
func testContributorButtonTapped() async throws { | ||
let url = URL(string: "https://github.com/DroidKaigi/conference-app-2023")! | ||
let store = TestStore(initialState: ContributorReducer.State()) { | ||
ContributorReducer() | ||
} | ||
|
||
await store.send(.view(.contributorButtonTapped(url))) { | ||
$0.url = IdentifiableURL(url) | ||
} | ||
} | ||
} | ||
|
||
enum ContributorTestError: Error { | ||
case fail | ||
} |
1 change: 1 addition & 0 deletions
1
app-ios/Tests/TimetableDetailFeatureTests/TimetableDetailTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters