Skip to content

Commit

Permalink
Fix perception check test to cover iOS 17+ and release-mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrtsa committed Dec 16, 2024
1 parent 34cb935 commit 32f56fa
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Tests/ComposableArchitectureTests/StorePerceptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,29 @@ final class StorePerceptionTests: BaseTCATestCase {

@MainActor
func testPerceptionCheck_AccessStateWithoutTracking() {
if #unavailable(iOS 17, macOS 14, tvOS 17, watchOS 10) {
@MainActor
struct FeatureView: View {
let store = Store(initialState: Feature.State()) {
Feature()
}
var body: some View {
Text(store.count.description)
}
@MainActor
struct FeatureView: View {
let store = Store(initialState: Feature.State()) {
Feature()
}
XCTExpectFailure {
render(FeatureView())
} issueMatcher: {
$0.compactDescription == """
failed - Perceptible state was accessed but is not being tracked. Track changes to state by \
wrapping your view in a 'WithPerceptionTracking' view. This must also be done for any \
escaping, trailing closures, such as 'GeometryReader', `LazyVStack` (and all lazy \
views), navigation APIs ('sheet', 'popover', 'fullScreenCover', etc.), and others.
"""
var body: some View {
Text(store.count.description)
}
}
guard isPerceptionCheckingEnabled else {
render(FeatureView())
return
}
XCTExpectFailure {
render(FeatureView())
} issueMatcher: {
$0.compactDescription == """
failed - Perceptible state was accessed but is not being tracked. Track changes to state by \
wrapping your view in a 'WithPerceptionTracking' view. This must also be done for any \
escaping, trailing closures, such as 'GeometryReader', `LazyVStack` (and all lazy \
views), navigation APIs ('sheet', 'popover', 'fullScreenCover', etc.), and others.
"""
}
}

@MainActor
Expand Down

0 comments on commit 32f56fa

Please sign in to comment.