spec/screen_helpers_spec.rb in ProMotion-0.5.2 vs spec/screen_helpers_spec.rb in ProMotion-0.6.0

- old
+ new

@@ -22,12 +22,41 @@ @screen.view.addSubview @subview @screen.remove @subview @screen.view.subviews.count.should == 0 end + it "should add a subview to another element" do + sub_subview = UIView.alloc.initWithFrame CGRectZero + @screen.add_to @subview, sub_subview + @subview.subviews.include?(sub_subview).should == true + end + + it "should add a subview to another element with attributes" do + sub_subview = UIView.alloc.initWithFrame CGRectZero + @screen.add_to @subview, sub_subview, { backgroundColor: UIColor.redColor } + @subview.subviews.last.backgroundColor.should == UIColor.redColor + end + end + describe "nav bar buttons" do + + before do + @screen = HomeScreen.new(nav_bar: true) + end + + it "should add a left nav bar button" do + @screen.set_nav_bar_left_button "Save", action: :save_something, type: UIBarButtonItemStyleDone + @screen.navigationItem.leftBarButtonItem.class.should == UIBarButtonItem + end + + it "should add a right nav bar button" do + @screen.set_nav_bar_right_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain + @screen.navigationItem.rightBarButtonItem.class.should == UIBarButtonItem + end + + end describe "screen navigation" do before do @screen = HomeScreen.new nav_bar: true @@ -77,16 +106,16 @@ animated.should == true end @screen.send(:present_modal_view_controller, new_screen, true) end - it "should push screen onto nav controller stack inside a tab bar" do - # TODO: Implement this test - end + # it "should push screen onto nav controller stack inside a tab bar" do + # # TODO: Implement this test + # end - it "should set the tab bar selectedIndex when opening a screen inside a tab bar" do - # TODO: Implement this test - end + # it "should set the tab bar selectedIndex when opening a screen inside a tab bar" do + # # TODO: Implement this test + # end it "should open a root screen if :close_all is provided" do @screen.mock!(:open_root_screen) { |screen| screen.should.be.instance_of BasicScreen } @screen.open_screen BasicScreen, close_all: true end