Add more tests
This commit is contained in:
parent
463fff2fae
commit
7aa9f1369c
|
@ -3,16 +3,15 @@
|
|||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objectVersion = 51;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
C068701C238DE85D00DAFD3D /* Introspect.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0687012238DE85D00DAFD3D /* Introspect.framework */; };
|
||||
C0687021238DE85D00DAFD3D /* TableViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0687020238DE85D00DAFD3D /* TableViewTests.swift */; };
|
||||
C0687023238DE85D00DAFD3D /* Introspect.h in Headers */ = {isa = PBXBuildFile; fileRef = C0687015238DE85D00DAFD3D /* Introspect.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
C068702D238DE8FD00DAFD3D /* Introspect.swift in Sources */ = {isa = PBXBuildFile; fileRef = C068702C238DE8FD00DAFD3D /* Introspect.swift */; };
|
||||
C068702F238DF01200DAFD3D /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = C068702E238DF01200DAFD3D /* TestUtils.swift */; };
|
||||
C0687031238DF3C900DAFD3D /* NavigationViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0687030238DF3C900DAFD3D /* NavigationViewTests.swift */; };
|
||||
C0687031238DF3C900DAFD3D /* IntrospectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0687030238DF3C900DAFD3D /* IntrospectTests.swift */; };
|
||||
C0C6D68E238E006B00DA6285 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C6D68D238E006B00DA6285 /* AppDelegate.swift */; };
|
||||
C0C6D690238E006B00DA6285 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C6D68F238E006B00DA6285 /* SceneDelegate.swift */; };
|
||||
C0C6D692238E006B00DA6285 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C6D691238E006B00DA6285 /* ContentView.swift */; };
|
||||
|
@ -41,11 +40,10 @@
|
|||
C0687015238DE85D00DAFD3D /* Introspect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Introspect.h; sourceTree = "<group>"; };
|
||||
C0687016238DE85D00DAFD3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C068701B238DE85D00DAFD3D /* IntrospectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IntrospectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C0687020238DE85D00DAFD3D /* TableViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewTests.swift; sourceTree = "<group>"; };
|
||||
C0687022238DE85D00DAFD3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C068702C238DE8FD00DAFD3D /* Introspect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Introspect.swift; sourceTree = "<group>"; };
|
||||
C068702E238DF01200DAFD3D /* TestUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
|
||||
C0687030238DF3C900DAFD3D /* NavigationViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewTests.swift; sourceTree = "<group>"; };
|
||||
C0687030238DF3C900DAFD3D /* IntrospectTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntrospectTests.swift; sourceTree = "<group>"; };
|
||||
C0C6D68B238E006B00DA6285 /* IntrospectExamples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IntrospectExamples.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C0C6D68D238E006B00DA6285 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
C0C6D68F238E006B00DA6285 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
|
@ -90,7 +88,6 @@
|
|||
9BBE78DB32CCDC560004DB54 /* Pods-IntrospectExamples.debug.xcconfig */,
|
||||
B826284199E111BBEA21E76B /* Pods-IntrospectExamples.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
@ -130,8 +127,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C0687022238DE85D00DAFD3D /* Info.plist */,
|
||||
C0687030238DF3C900DAFD3D /* NavigationViewTests.swift */,
|
||||
C0687020238DE85D00DAFD3D /* TableViewTests.swift */,
|
||||
C0687030238DF3C900DAFD3D /* IntrospectTests.swift */,
|
||||
C068702E238DF01200DAFD3D /* TestUtils.swift */,
|
||||
);
|
||||
path = IntrospectTests;
|
||||
|
@ -360,8 +356,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C0687031238DF3C900DAFD3D /* NavigationViewTests.swift in Sources */,
|
||||
C0687021238DE85D00DAFD3D /* TableViewTests.swift in Sources */,
|
||||
C0687031238DF3C900DAFD3D /* IntrospectTests.swift in Sources */,
|
||||
C068702F238DF01200DAFD3D /* TestUtils.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
import XCTest
|
||||
import SwiftUI
|
||||
|
||||
@testable import Introspect
|
||||
|
||||
private struct NavigationTestView: View {
|
||||
let spy: () -> Void
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
EmptyView()
|
||||
}
|
||||
.introspectNavigationController { navigationController in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ListTestView: View {
|
||||
|
||||
let spy1: () -> Void
|
||||
let spy2: () -> Void
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Text("Item 1")
|
||||
Text("Item 2")
|
||||
.introspectTableView { tableView in
|
||||
self.spy2()
|
||||
}
|
||||
}
|
||||
.introspectTableView { tableView in
|
||||
self.spy1()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScrollTestView: View {
|
||||
|
||||
let spy1: () -> Void
|
||||
let spy2: () -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
ScrollView {
|
||||
Text("Item 1")
|
||||
}
|
||||
.introspectScrollView { scrollView in
|
||||
self.spy1()
|
||||
}
|
||||
ScrollView {
|
||||
Text("Item 1")
|
||||
.introspectScrollView { scrollView in
|
||||
self.spy2()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct TextFieldTestView: View {
|
||||
let spy: () -> Void
|
||||
@State private var textFieldValue = ""
|
||||
var body: some View {
|
||||
TextField("Text Field", text: $textFieldValue)
|
||||
.introspectTextField { textField in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IntrospectTests: XCTestCase {
|
||||
func testNavigation() {
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
let view = NavigationTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
}
|
||||
|
||||
func testList() {
|
||||
|
||||
let expectation1 = XCTestExpectation()
|
||||
let expectation2 = XCTestExpectation()
|
||||
let view = ListTestView(
|
||||
spy1: { expectation1.fulfill() },
|
||||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
}
|
||||
|
||||
func testScrollView() {
|
||||
|
||||
let expectation1 = XCTestExpectation()
|
||||
let expectation2 = XCTestExpectation()
|
||||
let view = ScrollTestView(
|
||||
spy1: { expectation1.fulfill() },
|
||||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
}
|
||||
|
||||
func testTextField() {
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
let view = TextFieldTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import XCTest
|
||||
import SwiftUI
|
||||
|
||||
@testable import Introspect
|
||||
|
||||
private struct TestView: View {
|
||||
let spy: () -> Void
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
EmptyView()
|
||||
}
|
||||
.introspectNavigationController { navigationController in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NavigationViewTests: XCTestCase {
|
||||
func testCallsCustomize() {
|
||||
let expectation = XCTestExpectation()
|
||||
let view = TestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import XCTest
|
||||
import SwiftUI
|
||||
|
||||
@testable import Introspect
|
||||
|
||||
private struct TestView: View {
|
||||
let spy: () -> Void
|
||||
var body: some View {
|
||||
List {
|
||||
Text("Item 1")
|
||||
Text("Item 2")
|
||||
.introspectTableView { tableView in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TableViewTests: XCTestCase {
|
||||
func testCallsCustomize() {
|
||||
let expectation = XCTestExpectation()
|
||||
let view = TestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue