spec/unit/screen_helpers_spec.rb in ProMotion-0.7.5 vs spec/unit/screen_helpers_spec.rb in ProMotion-0.7.6
- old
+ new
@@ -106,25 +106,25 @@
describe "opening a screen" do
it "should create an instance from class when opening a new screen" do
- @screen.send(:setup_screen_for_open, BasicScreen).should.be.instance_of BasicScreen
+ @screen.send(:set_up_screen_for_open, BasicScreen).should.be.instance_of BasicScreen
end
it "should apply properties when opening a new screen" do
- new_screen = @screen.send(:setup_screen_for_open, BasicScreen, title: 'Some Title', modal: true, hide_tab_bar: true, nav_bar: true)
+ new_screen = @screen.send(:set_up_screen_for_open, BasicScreen, title: 'Some Title', modal: true, hide_tab_bar: true, nav_bar: true)
new_screen.parent_screen.should == @screen
new_screen.title.should == 'Some Title'
new_screen.modal?.should == true
new_screen.hidesBottomBarWhenPushed.should == true
new_screen.nav_bar?.should == true
end
it "should present the #main_controller when showing a modal screen" do
- new_screen = @screen.send(:setup_screen_for_open, BasicScreen, modal: true)
+ new_screen = @screen.send(:set_up_screen_for_open, BasicScreen, modal: true)
@screen.mock!('presentModalViewController:animated:') do |vc, animated|
vc.should == new_screen.main_controller
animated.should == true
end
@@ -149,19 +149,29 @@
screen.should.be.instance_of BasicScreen
animated.should == true
end
@screen.open BasicScreen, modal: true
end
-
+
it "should present a modal screen if open_modal is used" do
@screen.mock!(:present_modal_view_controller) do |screen, animated|
screen.should.be.instance_of BasicScreen
animated.should == true
end
@screen.open_modal BasicScreen
end
+ it "should respect animated property of opening modal screens" do
+ new_screen = @screen.send(:set_up_screen_for_open, BasicScreen)
+
+ @screen.mock!('presentModalViewController:animated:') do |vc, animated|
+ animated.should == false
+ end
+
+ @screen.send(:open, new_screen, animated: false, modal: true)
+ end
+
it "should open screen in tab bar if :in_tab is provided" do
@screen.stub!(:tab_bar, return: true)
@screen.mock!(:present_view_controller_in_tab_bar_controller) do |screen, tab_name|
screen.should.be.instance_of BasicScreen
tab_name.should == 'my_tab'
@@ -171,10 +181,18 @@
it "should pop onto navigation controller if current screen is on nav stack already" do
@screen.mock!(:push_view_controller) { |vc| vc.should.be.instance_of BasicScreen }
@screen.open BasicScreen
end
+
+ it "should ignore its own navigation controller if current screen has a navigation controller" do
+ basic = BasicScreen.new(nav_bar: true) # creates a dangling nav_bar that will be discarded.
+ @screen.open basic
+ basic.navigationController.should == @screen.navigationController
+ basic.navigation_controller.should == @screen.navigationController
+ @screen.navigation_controller.should == @screen.navigationController
+ end
it "should open the provided view controller as root view if no other conditions are met" do
parent_screen = HomeScreen.new
new_screen = BasicScreen.new
parent_screen.mock!(:open_root_screen) { |vc| vc.should.be == new_screen }
@@ -209,9 +227,21 @@
animated.should == true
completion.should.be.instance_of Proc
completion.call
end
@screen.close
+ end
+
+ it "should respect animated value for closing modal screens" do
+ parent_screen = HomeScreen.new
+ @screen.parent_screen = parent_screen
+ @screen.modal = true
+
+ parent_screen.mock!('dismissViewControllerAnimated:completion:') do |animated, completion|
+ animated.should == false
+ end
+
+ @screen.send(:close, animated: false)
end
it "#close should pop from the navigation controller" do
@screen.navigation_controller.mock!(:popViewControllerAnimated) { |animated| animated.should == true }
@screen.close