Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class AlertsAndConfirmationDialogsTests: XCTestCase {
@MainActor
func testAlert() async {
let store = TestStore(initialState: AlertAndConfirmationDialog.State()) {
AlertAndConfirmationDialog()
Expand Down Expand Up @@ -33,6 +33,7 @@ final class AlertsAndConfirmationDialogsTests: XCTestCase {
}
}

@MainActor
func testConfirmationDialog() async {
let store = TestStore(initialState: AlertAndConfirmationDialog.State()) {
AlertAndConfirmationDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class AnimationTests: XCTestCase {
@MainActor
func testRainbow() async {
let clock = TestClock()

Expand Down Expand Up @@ -58,6 +58,7 @@ final class AnimationTests: XCTestCase {
await clock.run()
}

@MainActor
func testReset() async {
let clock = TestClock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class BindingFormTests: XCTestCase {
@MainActor
func testBasics() async {
let store = TestStore(initialState: BindingForm.State()) {
BindingForm()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class SharedStateTests: XCTestCase {
@MainActor
func testTabSelection() async {
let store = TestStore(initialState: SharedState.State()) {
SharedState()
Expand All @@ -18,6 +18,7 @@ final class SharedStateTests: XCTestCase {
}
}

@MainActor
func testSharedCounts() async {
let store = TestStore(initialState: SharedState.State()) {
SharedState()
Expand All @@ -37,6 +38,7 @@ final class SharedStateTests: XCTestCase {
}
}

@MainActor
func testAlert() async {
let store = TestStore(initialState: SharedState.State()) {
SharedState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class EffectsBasicsTests: XCTestCase {
@MainActor
func testCountDown() async {
let store = TestStore(initialState: EffectsBasics.State()) {
EffectsBasics()
Expand All @@ -20,6 +20,7 @@ final class EffectsBasicsTests: XCTestCase {
}
}

@MainActor
func testNumberFact() async {
let store = TestStore(initialState: EffectsBasics.State()) {
EffectsBasics()
Expand All @@ -40,6 +41,7 @@ final class EffectsBasicsTests: XCTestCase {
}
}

@MainActor
func testDecrement() async {
let store = TestStore(initialState: EffectsBasics.State()) {
EffectsBasics()
Expand All @@ -55,6 +57,7 @@ final class EffectsBasicsTests: XCTestCase {
}
}

@MainActor
func testDecrementCancellation() async {
let store = TestStore(initialState: EffectsBasics.State()) {
EffectsBasics()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class EffectsCancellationTests: XCTestCase {
@MainActor
func testTrivia_SuccessfulRequest() async {
let store = TestStore(initialState: EffectsCancellation.State()) {
EffectsCancellation()
Expand All @@ -27,6 +27,7 @@ final class EffectsCancellationTests: XCTestCase {
}
}

@MainActor
func testTrivia_FailedRequest() async {
struct FactError: Equatable, Error {}
let store = TestStore(initialState: EffectsCancellation.State()) {
Expand All @@ -49,6 +50,7 @@ final class EffectsCancellationTests: XCTestCase {
// in the `.cancelButtonTapped` action of the `effectsCancellationReducer`. This will cause the
// test to fail, showing that we are exhaustively asserting that the effect truly is canceled and
// will never emit.
@MainActor
func testTrivia_CancelButtonCancelsRequest() async {
let store = TestStore(initialState: EffectsCancellation.State()) {
EffectsCancellation()
Expand All @@ -64,6 +66,7 @@ final class EffectsCancellationTests: XCTestCase {
}
}

@MainActor
func testTrivia_PlusMinusButtonsCancelsRequest() async {
let store = TestStore(initialState: EffectsCancellation.State()) {
EffectsCancellation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class LongLivingEffectsTests: XCTestCase {
@MainActor
func testReducer() async {
let (screenshots, takeScreenshot) = AsyncStream.makeStream(of: Void.self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class RefreshableTests: XCTestCase {
@MainActor
func testHappyPath() async {
let store = TestStore(initialState: Refreshable.State()) {
Refreshable()
Expand All @@ -22,6 +22,7 @@ final class RefreshableTests: XCTestCase {
}
}

@MainActor
func testUnhappyPath() async {
struct FactError: Equatable, Error {}

Expand All @@ -39,6 +40,7 @@ final class RefreshableTests: XCTestCase {
await store.receive(\.factResponse.failure)
}

@MainActor
func testCancellation() async {
let store = TestStore(initialState: Refreshable.State()) {
Refreshable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class TimersTests: XCTestCase {
@MainActor
func testStart() async {
let clock = TestClock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class WebSocketTests: XCTestCase {
@MainActor
func testWebSocketHappyPath() async {
let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self)
let messages = AsyncStream.makeStream(of: Result<WebSocketClient.Message, Error>.self)
Expand Down Expand Up @@ -56,6 +56,7 @@ final class WebSocketTests: XCTestCase {
await store.finish()
}

@MainActor
func testWebSocketSendFailure() async {
let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self)
let messages = AsyncStream.makeStream(of: Result<WebSocketClient.Message, Error>.self)
Expand Down Expand Up @@ -102,6 +103,7 @@ final class WebSocketTests: XCTestCase {
await store.finish()
}

@MainActor
func testWebSocketPings() async {
let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self)
let clock = TestClock()
Expand Down Expand Up @@ -136,6 +138,7 @@ final class WebSocketTests: XCTestCase {
}
}

@MainActor
func testWebSocketConnectError() async {
let actions = AsyncStream.makeStream(of: WebSocketClient.Action.self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class RecursionTests: XCTestCase {
@MainActor
func testAddRow() async {
let store = TestStore(initialState: Nested.State(id: UUID())) {
Nested()
Expand All @@ -21,6 +21,7 @@ final class RecursionTests: XCTestCase {
}
}

@MainActor
func testChangeName() async {
let store = TestStore(initialState: Nested.State(id: UUID())) {
Nested()
Expand All @@ -31,6 +32,7 @@ final class RecursionTests: XCTestCase {
}
}

@MainActor
func testDeleteRow() async {
let store = TestStore(
initialState: Nested.State(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class ReusableComponentsFavoritingTests: XCTestCase {
@MainActor
func testHappyPath() async {
let clock = TestClock()

Expand Down Expand Up @@ -50,6 +50,7 @@ final class ReusableComponentsFavoritingTests: XCTestCase {
await store.receive(\.episodes[id:episodes[1].id].favorite.response.success)
}

@MainActor
func testUnhappyPath() async {
let episodes: IdentifiedArrayOf<Episode.State> = [
Episode.State(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import XCTest

@testable import SwiftUICaseStudies

@MainActor
final class ReusableComponentsDownloadComponentTests: XCTestCase {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)

@MainActor
func testDownloadFlow() async {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = TestStore(
initialState: DownloadComponent.State(
id: 1,
Expand All @@ -17,26 +16,28 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
) {
DownloadComponent()
} withDependencies: {
$0.downloadClient.download = { @Sendable _ in self.download.stream }
$0.downloadClient.download = { @Sendable _ in download.stream }
}

await store.send(.buttonTapped) {
$0.mode = .startingToDownload
}

self.download.continuation.yield(.updateProgress(0.2))
download.continuation.yield(.updateProgress(0.2))
await store.receive(\.downloadClient.success.updateProgress) {
$0.mode = .downloading(progress: 0.2)
}

self.download.continuation.yield(.response(Data()))
self.download.continuation.finish()
download.continuation.yield(.response(Data()))
download.continuation.finish()
await store.receive(\.downloadClient.success.response) {
$0.mode = .downloaded
}
}

@MainActor
func testCancelDownloadFlow() async {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = TestStore(
initialState: DownloadComponent.State(
id: 1,
Expand All @@ -46,14 +47,14 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
) {
DownloadComponent()
} withDependencies: {
$0.downloadClient.download = { @Sendable _ in self.download.stream }
$0.downloadClient.download = { @Sendable _ in download.stream }
}

await store.send(.buttonTapped) {
$0.mode = .startingToDownload
}

self.download.continuation.yield(.updateProgress(0.2))
download.continuation.yield(.updateProgress(0.2))
await store.receive(\.downloadClient.success.updateProgress) {
$0.mode = .downloading(progress: 0.2)
}
Expand All @@ -77,7 +78,9 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
}
}

@MainActor
func testDownloadFinishesWhileTryingToCancel() async {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = TestStore(
initialState: DownloadComponent.State(
id: 1,
Expand All @@ -87,7 +90,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
) {
DownloadComponent()
} withDependencies: {
$0.downloadClient.download = { @Sendable _ in self.download.stream }
$0.downloadClient.download = { @Sendable _ in download.stream }
}

let task = await store.send(.buttonTapped) {
Expand All @@ -107,8 +110,8 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
}
}

self.download.continuation.yield(.response(Data()))
self.download.continuation.finish()
download.continuation.yield(.response(Data()))
download.continuation.finish()
await store.receive(\.downloadClient.success.response) {
$0.alert = nil
$0.mode = .downloaded
Expand All @@ -117,7 +120,9 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
await task.finish()
}

@MainActor
func testDeleteDownloadFlow() async {
let download = AsyncThrowingStream.makeStream(of: DownloadClient.Event.self)
let store = TestStore(
initialState: DownloadComponent.State(
id: 1,
Expand All @@ -127,7 +132,7 @@ final class ReusableComponentsDownloadComponentTests: XCTestCase {
) {
DownloadComponent()
} withDependencies: {
$0.downloadClient.download = { @Sendable _ in self.download.stream }
$0.downloadClient.download = { @Sendable _ in download.stream }
}

await store.send(.buttonTapped) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import XCTest

@testable import UIKitCaseStudies

@MainActor
final class UIKitCaseStudiesTests: XCTestCase {
@MainActor
func testCountDown() async {
let store = TestStore(initialState: Counter.State()) {
Counter()
Expand All @@ -18,6 +18,7 @@ final class UIKitCaseStudiesTests: XCTestCase {
}
}

@MainActor
func testCountDownList() async {
let firstState = Counter.State()
let secondState = Counter.State()
Expand Down
Loading