-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00825e6
commit a605e12
Showing
8 changed files
with
127 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import UIKit | ||
@testable import VoirBuilder | ||
|
||
final class MockUIView: UIView { | ||
var mockTraitCollection: UITraitCollection? | ||
|
||
override var traitCollection: UITraitCollection { | ||
mockTraitCollection ?? super.traitCollection | ||
} | ||
|
||
private(set) var notifyOrientationCalled = false | ||
override func notifyOrientation() { | ||
super.notifyOrientation() | ||
notifyOrientationCalled = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import UIKit | ||
@testable import VoirBuilder | ||
|
||
final class MockUIViewController: UIViewController { | ||
|
||
private(set) var notifyOrientationCalled = false | ||
override func notifyOrientation() { | ||
super.notifyOrientation() | ||
notifyOrientationCalled = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import UIKit | ||
import XCTest | ||
@testable import VoirBuilder | ||
|
||
final class VoirBuilderBindTests: XCTestCase { | ||
func testUISlider_Binding() throws { | ||
let control = UISlider() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUIButton_Binding() throws { | ||
let control = UIButton() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUISwitch_Binding() throws { | ||
let control = UISwitch() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUISegmentedControl_Binding() throws { | ||
let control = UISegmentedControl() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUIStepper_Binding() throws { | ||
let control = UIStepper() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUITextField_Binding() throws { | ||
let control = UITextField() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUIDatePicker_Binding() throws { | ||
let control = UIDatePicker() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
|
||
func testUIPageControl_Binding() throws { | ||
let control = UIPageControl() | ||
control => { } | ||
XCTAssertEqual(control.allTargets.count, 1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import XCTest | ||
@testable import VoirBuilder | ||
|
||
final class VoirHookerTests: XCTestCase { | ||
func testUIView_whenDidChangeTraitCollection() { | ||
let view = MockUIView() | ||
|
||
view.traitCollectionDidChange(nil) | ||
|
||
XCTAssertTrue(view.notifyOrientationCalled) | ||
} | ||
|
||
func testUIViewController_whenViewDidLoad() { | ||
let viewController = MockUIViewController() | ||
|
||
viewController.viewDidLoad() | ||
|
||
XCTAssertTrue(viewController.notifyOrientationCalled) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters