File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 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 {
6666
6767 XCTAssert ( sut. next === expectedResult)
6868 }
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+ }
69110}
70111
71112final class MockViewController : ViewController {
You can’t perform that action at this time.
0 commit comments