-
Notifications
You must be signed in to change notification settings - Fork 150
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
1 parent
3049426
commit c844e4f
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import XCTest | ||
import SwiftUI | ||
@testable import ViewInspector | ||
|
||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) | ||
final class CustomInspectableTests: XCTestCase { | ||
|
||
func testCustomInspectableViewRepresentable() throws { | ||
let sut = CustomViewRepresentable(labels: ["1", "abc"]) | ||
XCTAssertNoThrow(try sut.inspect().find(text: "abc")) | ||
} | ||
|
||
} | ||
|
||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) | ||
private struct CustomViewRepresentable: UIViewRepresentable, CustomInspectable { | ||
|
||
let labels: [String] | ||
|
||
@ViewBuilder | ||
var inspectableRepresentation: some View { | ||
let indexedLabels = Array(labels.enumerated()) | ||
ForEach(indexedLabels, id: \.0) { _, label in | ||
Text(label) | ||
} | ||
} | ||
|
||
func makeUIView(context: Context) -> UIView { | ||
UIView() // This could be a UICollectionView, a UIStackView, or anything else | ||
} | ||
|
||
func updateUIView(_ view: UIView, context: Context) { } | ||
} |
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