spec/unit/screen_spec.rb in ProMotion-2.3.1 vs spec/unit/screen_spec.rb in ProMotion-2.4.0

- old
+ new

@@ -314,78 +314,78 @@ describe "screen with toolbar" do it "showing" do # Simulate AppDelegate setup of main screen - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.on_load screen.navigationController.toolbarHidden?.should == false end it "hidden" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: false + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: false) screen.on_load screen.navigationController.toolbarHidden?.should == true end it "adds a single item" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.on_load screen.set_toolbar_button([{title: "Testing Toolbar"}]) screen.navigationController.toolbar.items.should.be.instance_of Array screen.navigationController.toolbar.items.count.should == 1 screen.navigationController.toolbar.items.first.should.be.instance_of UIBarButtonItem screen.navigationController.toolbar.items.first.title.should == "Testing Toolbar" end it "adds multiple items" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.set_toolbar_buttons [{title: "Testing Toolbar"}, {title: "Another Test"}] screen.navigationController.toolbar.items.should.be.instance_of Array screen.navigationController.toolbar.items.count.should == 2 screen.navigationController.toolbar.items.first.title.should == "Testing Toolbar" screen.navigationController.toolbar.items.last.title.should == "Another Test" end it "shows the toolbar when setting items" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: false + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: false) screen.on_load screen.navigationController.toolbarHidden?.should == true screen.set_toolbar_button([{title: "Testing Toolbar"}], false) screen.navigationController.toolbarHidden?.should == false end it "doesn't show the toolbar when passed nil" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.on_load screen.set_toolbar_button(nil, false) screen.navigationController.toolbarHidden?.should == true end it "doesn't show the toolbar when passed false" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.on_load screen.set_toolbar_button(false, false) screen.navigationController.toolbarHidden?.should == true end it "hides the toolbar when passed nil" do - screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) screen.on_load screen.set_toolbar_button([{title: "Testing Toolbar"}], false) screen.navigationController.toolbarHidden?.should == false screen.set_toolbar_button(nil, false) screen.navigationController.toolbarHidden?.should == true end end -describe 'toolbar tinted buttons' do +describe "toolbar tinted buttons" do before do - @screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true + @screen = HomeScreen.new(nav_bar: true, modal: true, toolbar: true) @screen.on_load end it "creates string toolbar buttons with tint colors" do @screen.set_toolbar_button([{title: "Testing Toolbar", tint_color: UIColor.redColor}]) @@ -401,5 +401,30 @@ @screen.set_toolbar_button([{system_item: :reply, tint_color: UIColor.redColor}]) @screen.navigationController.toolbar.items.first.tintColor.should == UIColor.redColor end end + +describe "child screen management" do + before do + @screen = HomeScreen.new + @child = BasicScreen.new + end + + it "#add_child_screen" do + @screen.add_child_screen @child + @screen.childViewControllers.should.include(@child) + @screen.childViewControllers.length.should == 1 + @child.parent_screen.should == @screen + end + + it "#remove_child_screen" do + @screen.add_child_screen @child + @screen.childViewControllers.should.include(@child) + @screen.remove_child_screen @child + @screen.childViewControllers.length.should == 0 + @child.parent_screen.should == nil + end + +end + +