Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring TCA tutorial content #22

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(tca): start testing counter
  • Loading branch information
dirtyhenry committed Dec 19, 2024
commit 22c8702ef32666677c159bd8da4c0fe2c9958ab6
4 changes: 4 additions & 0 deletions Examples/HoodsApp/HoodsApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
0004E7C42B86A2F4008EBCF9 /* CopyTextDemoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0004E7C32B86A2F4008EBCF9 /* CopyTextDemoView.swift */; };
0004E7C62B86A313008EBCF9 /* CopyTextDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0004E7C52B86A313008EBCF9 /* CopyTextDemoTests.swift */; };
004F27742AE6DF3A00D118BA /* ComposableArchitecture in Frameworks */ = {isa = PBXBuildFile; productRef = 004F27732AE6DF3A00D118BA /* ComposableArchitecture */; };
0068F7132D1486A000295745 /* CounterFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0068F7122D1486A000295745 /* CounterFeatureTests.swift */; };
00BC0F6D2B632FE2000FC408 /* HoodsTestsTools in Frameworks */ = {isa = PBXBuildFile; productRef = 00BC0F6C2B632FE2000FC408 /* HoodsTestsTools */; };
00D120752C88E997001CDA65 /* ImagePickerFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D120742C88E997001CDA65 /* ImagePickerFeature.swift */; };
00D120772C88E99C001CDA65 /* ImagePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D120762C88E99C001CDA65 /* ImagePickerView.swift */; };
Expand Down Expand Up @@ -43,6 +44,7 @@
0004E7C12B86A2E8008EBCF9 /* CopyTextDemoFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyTextDemoFeature.swift; sourceTree = "<group>"; };
0004E7C32B86A2F4008EBCF9 /* CopyTextDemoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyTextDemoView.swift; sourceTree = "<group>"; };
0004E7C52B86A313008EBCF9 /* CopyTextDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyTextDemoTests.swift; sourceTree = "<group>"; };
0068F7122D1486A000295745 /* CounterFeatureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CounterFeatureTests.swift; sourceTree = "<group>"; };
00CC6CBA2A68425F0093300A /* DefaultTestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = DefaultTestPlan.xctestplan; sourceTree = "<group>"; };
00D120742C88E997001CDA65 /* ImagePickerFeature.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImagePickerFeature.swift; sourceTree = "<group>"; };
00D120762C88E99C001CDA65 /* ImagePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImagePickerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -167,6 +169,7 @@
00CC6CBA2A68425F0093300A /* DefaultTestPlan.xctestplan */,
00DCF4432B62CFF800082C13 /* MailButtonDemoTests.swift */,
0004E7C52B86A313008EBCF9 /* CopyTextDemoTests.swift */,
0068F7122D1486A000295745 /* CounterFeatureTests.swift */,
);
path = HoodsAppTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -311,6 +314,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0068F7132D1486A000295745 /* CounterFeatureTests.swift in Sources */,
0004E7C62B86A313008EBCF9 /* CopyTextDemoTests.swift in Sources */,
00F6F5692A66CBE50088B530 /* HoodsAppTests.swift in Sources */,
00DCF4442B62CFF800082C13 /* MailButtonDemoTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import SwiftUI

@Reducer
struct CounterFeature {
// An equatable state is required by the TestStore
@ObservableState
struct State {
struct State: Equatable {
var count = 0
var fact: String?
var isLoading = false
Expand Down
21 changes: 21 additions & 0 deletions Examples/HoodsApp/HoodsAppTests/CounterFeatureTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ComposableArchitecture
import Testing

@testable import HoodsApp

@MainActor
struct CounterFeatureTests {
@Test
func basics() async {
let store = TestStore(initialState: CounterFeature.State()) {
CounterFeature()
}

await store.send(.incrementButtonTapped) {
$0.count = 1
}
await store.send(.decrementButtonTapped) {
$0.count = 0
}
}
}