diff --git a/Tests/DatadogTests/Datadog/RUM/AutoInstrumentation/Views/UIKitRUMViewsPredicateTests.swift b/Tests/DatadogTests/Datadog/RUM/AutoInstrumentation/Views/UIKitRUMViewsPredicateTests.swift index ced5ee0ad7..e26a0be56c 100644 --- a/Tests/DatadogTests/Datadog/RUM/AutoInstrumentation/Views/UIKitRUMViewsPredicateTests.swift +++ b/Tests/DatadogTests/Datadog/RUM/AutoInstrumentation/Views/UIKitRUMViewsPredicateTests.swift @@ -7,6 +7,10 @@ import XCTest import Datadog +#if canImport(SwiftUI) +import SwiftUI +#endif + class UIKitRUMViewsPredicateTests: XCTestCase { func testGivenDefaultPredicate_whenAskingForCustomSwiftViewController_itNamesTheViewByItsClassName() { // Given @@ -47,4 +51,21 @@ class UIKitRUMViewsPredicateTests: XCTestCase { // Then XCTAssertNil(rumView) } + +#if canImport(SwiftUI) + func testGivenDefaultPredicate_whenAskingSwiftUIViewController_itReturnsNoView() { + guard #available(iOS 13, *) else { + return + } + // Given + let predicate = DefaultUIKitRUMViewsPredicate() + + // When + let swiftUIGistingController = UIHostingController(rootView: EmptyView()) + let rumView = predicate.rumView(for: swiftUIGistingController) + + // Then + XCTAssertNil(rumView) + } +#endif } diff --git a/Tests/DatadogTests/Datadog/Utils/SwiftUIExtensionsTests.swift b/Tests/DatadogTests/Datadog/Utils/SwiftUIExtensionsTests.swift index 26b56e04a3..2a2aead944 100644 --- a/Tests/DatadogTests/Datadog/Utils/SwiftUIExtensionsTests.swift +++ b/Tests/DatadogTests/Datadog/Utils/SwiftUIExtensionsTests.swift @@ -4,8 +4,9 @@ * Copyright 2019-2020 Datadog, Inc. */ -import XCTest #if canImport(SwiftUI) + +import XCTest import SwiftUI @testable import Datadog