-
Notifications
You must be signed in to change notification settings - Fork 157
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
Alexey Naumov
committed
Aug 26, 2023
1 parent
0f872b5
commit 0def023
Showing
2 changed files
with
24 additions
and
10 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
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,26 +1,40 @@ | ||
import XCTest | ||
import SwiftUI | ||
|
||
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) | ||
final class ViewThatFitsTests: XCTestCase { | ||
|
||
func testAllEnclosedChildTextViews() throws { | ||
guard #available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
else { throw XCTSkip() } | ||
This comment has been minimized.
Sorry, something went wrong. |
||
let sut = TestViewThatFits() | ||
let longText = try sut.inspect().find(text: "Very long text that will only get picked if there is available space.") | ||
let shortText = try sut.inspect().find(text: "Short text") | ||
let shortString = TestViewThatFits.shortString | ||
let longString = TestViewThatFits.longString | ||
let longText = try sut.inspect().find(text: longString) | ||
let shortText = try sut.inspect().find(text: shortString) | ||
|
||
XCTAssertEqual(try longText.string(), "Very long text that will only get picked if there is available space.") | ||
XCTAssertEqual(try shortText.string(), "Short text") | ||
XCTAssertEqual(try longText.string(), longString) | ||
XCTAssertEqual(try shortText.string(), shortString) | ||
} | ||
} | ||
|
||
// MARK: - TestViewThatFits | ||
|
||
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) | ||
struct TestViewThatFits: View { | ||
private struct TestViewThatFits: View { | ||
|
||
static var longString: String { | ||
"Very long text that will only get picked if there is available space." | ||
} | ||
|
||
static var shortString: String { | ||
"Short text" | ||
} | ||
|
||
var body: some View { | ||
ViewThatFits { | ||
Text("Very long text that will only get picked if there is available space.") | ||
Text("Short text") | ||
Text(Self.longString) | ||
Text(Self.shortString) | ||
} | ||
} | ||
} |
TIL about
XCTSkip()
!