File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,47 @@ final class ViewControllerTests: XCTestCase {
66
66
67
67
XCTAssert ( sut. next === expectedResult)
68
68
}
69
+
70
+ func testViewDidLoadMethodCalledAfterLazyViewLoad( ) {
71
+ let sut = MockViewController ( )
72
+
73
+ let expectation = self . expectation ( description: " viewDidLoad should be called " )
74
+
75
+ sut. viewDidLoadBlock = {
76
+ expectation. fulfill ( )
77
+ }
78
+
79
+ _ = sut. view
80
+
81
+ wait ( for: [ expectation] , timeout: 0.1 )
82
+ }
83
+
84
+ func testViewDidLoadMethodCalledAfterManualViewLoad( ) {
85
+ let sut = MockViewController ( )
86
+
87
+ let expectation = self . expectation ( description: " viewDidLoad should be called " )
88
+
89
+ sut. viewDidLoadBlock = {
90
+ expectation. fulfill ( )
91
+ }
92
+
93
+ sut. loadViewIfNeeded ( )
94
+
95
+ wait ( for: [ expectation] , timeout: 0.1 )
96
+ }
97
+
98
+ func testViewDidLoadMethodNotCalledIfViewNotLoaded( ) {
99
+ let sut = MockViewController ( )
100
+
101
+ let expectation = self . expectation ( description: " viewDidLoad should not be called " )
102
+ expectation. isInverted = true
103
+
104
+ sut. viewDidLoadBlock = {
105
+ expectation. fulfill ( )
106
+ }
107
+
108
+ wait ( for: [ expectation] , timeout: 0.1 )
109
+ }
69
110
}
70
111
71
112
final class MockViewController : ViewController {
You can’t perform that action at this time.
0 commit comments