Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created November 12, 2022 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/e32a0e4a78560ca397ae2a8716437a0c to your computer and use it in GitHub Desktop.
Save laevandus/e32a0e4a78560ca397ae2a8716437a0c to your computer and use it in GitHub Desktop.
@testable import SwiftUIExampleViewInspector
import SwiftUI
import ViewInspector
import XCTest
// Do not forget this!
extension ContentView: Inspectable {}
final class ContentViewTests: XCTestCase {
func testInitialTitle() throws {
let contentView = ContentView()
let text = try contentView.inspect()
.find(text: "Hello World!")
let font = try text.attributes().font()
XCTAssertEqual(font, Font.title)
}
func testWelcomeTitle() throws {
let viewModel = ContentView.ViewModel()
viewModel.style = .welcome
let contentView = ContentView(viewModel: viewModel)
_ = try contentView.inspect().find(text: "Welcome World!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment