File tree Expand file tree Collapse file tree
Example/ExampleSSDataSourcesTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,4 +189,36 @@ - (void)testBuildingArrayOfIndexPathsWithIndexSet
189189 expect (indexPaths).to .equal (@[[NSIndexPath indexPathForRow: 1 inSection: 0 ]]);
190190}
191191
192+ #pragma mark Empty View
193+
194+ - (void )testBasicEmptyViewVisibility
195+ {
196+ // hidden empty view
197+ SSArrayDataSource *arrayDataSource = [[SSArrayDataSource alloc ] initWithItems: @[ @" item" ]];
198+ arrayDataSource.tableView = tableView;
199+ arrayDataSource.emptyView = [UIView new ];
200+ expect (arrayDataSource.emptyView .hidden ).to .beTruthy ();
201+
202+ // visible empty view
203+ [arrayDataSource removeAllItems ];
204+ expect (arrayDataSource.emptyView .hidden ).to .beFalsy ();
205+ }
206+
207+ - (void )testEmptyViewSetUpIsNotDependentOnParentViewConfiguration
208+ {
209+ // The intent is to ensure that you can set up your emptyView *before* you
210+ // assign the data source’s table or collection view.
211+ SSArrayDataSource *arrayDataSource;
212+
213+ arrayDataSource = [[SSArrayDataSource alloc ] initWithItems: @[]];
214+ arrayDataSource.emptyView = [UIView new ];
215+ arrayDataSource.tableView = tableView;
216+ expect (arrayDataSource.emptyView .hidden ).to .beFalsy ();
217+
218+ arrayDataSource = [[SSArrayDataSource alloc ] initWithItems: @[]];
219+ arrayDataSource.emptyView = [UIView new ];
220+ arrayDataSource.collectionView = collectionView;
221+ expect (arrayDataSource.emptyView .hidden ).to .beFalsy ();
222+ }
223+
192224@end
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ - (void)setTableView:(UITableView *)tableView {
104104 if (tableView) {
105105 tableView.dataSource = self;
106106 }
107+
108+ [self _updateEmptyView ];
107109}
108110
109111- (void )setCollectionView : (UICollectionView *)collectionView {
@@ -112,6 +114,8 @@ - (void)setCollectionView:(UICollectionView *)collectionView {
112114 if (collectionView) {
113115 collectionView.dataSource = self;
114116 }
117+
118+ [self _updateEmptyView ];
115119}
116120
117121#pragma mark - UITableViewDataSource
You can’t perform that action at this time.
0 commit comments