Skip to content

Commit

Permalink
fix tests for legacy xcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Naumov committed Sep 17, 2024
1 parent 23d6fab commit 372d4d6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Tests/ViewInspectorTests/InspectorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,13 @@ final class InspectableViewModifiersTests: XCTestCase {
TestPrintView().padding()
})
})
#if compiler(<6)
let sut = try view.inspect().anyView().group().emptyView(1).overlay()
.hStack().view(TestPrintView.self, 1).text()
#else
let sut = try view.inspect().anyView().group().emptyView(1).overlay()
.hStack().view(TestPrintView.self, 1).implicitAnyView().text().parent()
#endif
// Cannot use `XCTAssertThrows` because test target changes name
// between ViewInspectorTests and ViewInspector_Unit_Tests under cocoapods tests
// ViewInspectorTests.TestPrintView vs ViewInspector_Unit_Tests.TestPrintView
Expand Down
4 changes: 2 additions & 2 deletions Tests/ViewInspectorTests/SwiftUI/AlertTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ final class AlertIOS15Tests: XCTestCase {
XCTAssertEqual(try message.string(), "Message: abc")
#if compiler(<6)
XCTAssertEqual(message.pathToRoot,
"alert().message().hStack().text(0)")
"emptyView().alert().message().hStack().text(0)")
let secondButtonLabel = try alert.actions().button(1).labelView().text()
XCTAssertEqual(try secondButtonLabel.string(), "Second")
XCTAssertEqual(secondButtonLabel.pathToRoot,
"alert().actions().button(1).labelView().text()")
"emptyView().alert().actions().button(1).labelView().text()")
let searchLabel = try sut.inspect().find(button: "Second")
XCTAssertEqual(searchLabel.pathToRoot,
"emptyView().alert().actions().button(1)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ final class ConditionalContentTests: XCTestCase {

func testRetainsModifiers() throws {
let sut = ConditionalViewWithModifier(value: true)
#if compiler(<6)
let text = try sut.inspect().text()
#else
let text = try sut.inspect().implicitAnyView().anyView().text()
#endif
XCTAssertEqual(try text.string(), "True")
#if compiler(<6)
XCTAssertEqual(try sut.inspect().text().padding(),
EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
#else
XCTAssertEqual(try sut.inspect().implicitAnyView().anyView().padding(),
EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
#endif
}
}

Expand Down
6 changes: 4 additions & 2 deletions Tests/ViewInspectorTests/SwiftUI/FullScreenCoverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ final class FullScreenCoverTests: XCTestCase {
.anyView().emptyView().fullScreenCover().text(0)
""")
#endif
let title2 = try sut.inspect().implicitAnyView().hStack().anyView(0).anyView().fullScreenCover().text(0)
XCTAssertEqual(try title2.string(), "title_3")
#if compiler(<6)
let title2 = try sut.inspect().implicitAnyView().hStack().emptyView(0).fullScreenCover(1).text(0)
XCTAssertEqual(try title2.string(), "title_3")
XCTAssertEqual(title2.pathToRoot,
"view(FullScreenCoverFindTestView.self).hStack().emptyView(0).fullScreenCover(1).text(0)")
XCTAssertEqual(try sut.inspect().find(ViewType.FullScreenCover.self).text(0).string(), "title_1")
#else
let title2 = try sut.inspect().implicitAnyView().hStack().anyView(0).anyView().fullScreenCover().text(0)
XCTAssertEqual(try title2.string(), "title_3")
XCTAssertEqual(title2.pathToRoot,
"view(FullScreenCoverFindTestView.self).anyView().hStack().anyView(0).anyView().fullScreenCover().text(0)")
XCTAssertEqual(try sut.inspect().find(ViewType.FullScreenCover.self, skipFound: 1).text(0).string(), "title_1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !os(watchOS) && !os(tvOS)
#if os(iOS)

import XCTest
import SwiftUI
Expand Down

0 comments on commit 372d4d6

Please sign in to comment.