Skip to content

Commit

Permalink
RUMM-1615 Add DefaultUIKitRUMViewsPredicate test for SwiftUI
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Oct 20, 2021
1 parent 40a1150 commit 45441bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import XCTest
import Datadog

#if canImport(SwiftUI)
import SwiftUI
#endif

class UIKitRUMViewsPredicateTests: XCTestCase {
func testGivenDefaultPredicate_whenAskingForCustomSwiftViewController_itNamesTheViewByItsClassName() {
// Given
Expand Down Expand Up @@ -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<EmptyView>(rootView: EmptyView())
let rumView = predicate.rumView(for: swiftUIGistingController)

// Then
XCTAssertNil(rumView)
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* Copyright 2019-2020 Datadog, Inc.
*/

import XCTest
#if canImport(SwiftUI)

import XCTest
import SwiftUI
@testable import Datadog

Expand Down

0 comments on commit 45441bd

Please sign in to comment.