spec/unit/tables/table_module_spec.rb in ProMotion-2.4.2 vs spec/unit/tables/table_module_spec.rb in ProMotion-2.5.0.beta1
- old
+ new
@@ -39,10 +39,20 @@
},
}
})
end
+ def proc_cell
+ custom_cell.merge({
+ action: -> (args, index_path) {
+ args[:data].should == [ "lots", "of", "data" ]
+ index_path.section.should == 7
+ index_path.row.should == 0
+ }
+ })
+ end
+
def default_cell_height
return UITableViewAutomaticDimension if TestHelper.ios8
return 97.0 if TestHelper.ios7 # Normally 44, but 97 because of `row_height` designation
end
@@ -67,24 +77,31 @@
},{
title: "Custom section title 1", title_view: CustomTitleView, cells: [ ]
},{
title: "Custom section title 2", title_view: CustomTitleView.new, title_view_height: 50, cells: [ ]
},{
- title: "Action WIth Index Path Group", cells: [ cell_factory(title: "IndexPath Group 1", action: :tests_index_path) ]
+ title: "Action With Index Path Group", cells: [ cell_factory(title: "IndexPath Group 1", action: :tests_index_path) ]
+ }, {
+ title: "Action With A Proc", cells: [ proc_cell ]
+ },{
+ title: "test 40", title_view: DynamicHeightTitleView40, cells: []
+ }, {
+ title: "test 121", title_view: DynamicHeightTitleView121, cells: []
}]
end
@subject.on_load
@ip = NSIndexPath.indexPathForRow(1, inSection: 2) # Cell 3-2
@custom_ip = NSIndexPath.indexPathForRow(0, inSection: 3) # Cell "Crazy Full Featured Cell"
+ @proc_cell = NSIndexPath.indexPathForRow(0, inSection: 7)
@subject.update_table_data
end
it "should have the right number of sections" do
- @subject.numberOfSectionsInTableView(@subject.table_view).should == 7
+ @subject.numberOfSectionsInTableView(@subject.table_view).should == 10
end
it "should set the section titles" do
@subject.tableView(@subject.table_view, titleForHeaderInSection:0).should == "Table cell group 1"
@subject.tableView(@subject.table_view, titleForHeaderInSection:1).should == "Table cell group 2"
@@ -132,10 +149,14 @@
end
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
end
+ it "should trigger the proc" do
+ @subject.tableView(@subject.table_view, didSelectRowAtIndexPath: @proc_cell)
+ end
+
it "should return an NSIndexPath when the action has two parameters" do
ip = NSIndexPath.indexPathForRow(0, inSection: 6)
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:ip)
@@ -195,9 +216,14 @@
end
it "should use the instantiated section view if one is specified" do
cell = @subject.tableView(@subject.table_view, viewForHeaderInSection: 5)
cell.should.be.kind_of(CustomTitleView)
+ end
+
+ it "should set the height of a title view when the method `height` is implemented" do
+ @subject.tableView(@subject.table_view, heightForHeaderInSection:8).should == 40.0
+ @subject.tableView(@subject.table_view, heightForHeaderInSection:9).should == 121.0
end
end
describe "header view modifications" do