spec/unit/screen_spec.rb in ProMotion-2.4.2 vs spec/unit/screen_spec.rb in ProMotion-2.5.0.beta1

- old
+ new

@@ -4,10 +4,20 @@ # Simulate AppDelegate setup of main screen @screen = HomeScreen.new modal: true, nav_bar: true @screen.on_load end + it "does not have a default title" do + screen = UntitledScreen.new + screen.title.should == nil + end + + it "does not display a default title in the nav bar" do + screen = UntitledScreen.new + screen.navigationItem.title.should == nil + end + it "should store title" do HomeScreen.title.should == "Home" end it "should set default title on new instances" do @@ -22,16 +32,10 @@ it "should not let the instance reset the default title" do @screen.title = "instance method" HomeScreen.title.should != 'instance method' end - it "should have a default UIStatusBar style" do - @screen.view_will_appear(false) - UIApplication.sharedApplication.isStatusBarHidden.should == false - UIApplication.sharedApplication.statusBarStyle.should == UIStatusBarStyleDefault - end - it "should set the UIStatusBar style to :none" do @screen.class.status_bar :none @screen.view_will_appear(false) UIApplication.sharedApplication.isStatusBarHidden.should == true end @@ -59,10 +63,17 @@ @screen.view_will_appear(false) UIApplication.sharedApplication.isStatusBarHidden.should == false UIApplication.sharedApplication.statusBarStyle.should == UIStatusBarStyleLightContent end + it "should default to a hidden UIStatusBar if already hidden" do + UIApplication.sharedApplication.setStatusBarHidden(true, withAnimation: UIStatusBarAnimationNone) + @screen.class.status_bar :default + @screen.view_will_appear(false) + UIApplication.sharedApplication.isStatusBarHidden.should == true + end + it "should set the tab bar item with a system item" do @screen.set_tab_bar_item system_item: :contacts comparison = UITabBarItem.alloc.initWithTabBarSystemItem(UITabBarSystemItemContacts, tag: 0) @screen.tabBarItem.systemItem.should == comparison.systemItem @screen.tabBarItem.tag.should == comparison.tag @@ -195,9 +206,36 @@ end it "-didRotateFromInterfaceOrientation" do @screen.mock!(:on_rotate) { true } @screen.didRotateFromInterfaceOrientation(UIInterfaceOrientationPortrait).should == true + end + + end + + describe "memory warnings" do + + it "should call didReceiveMemoryWarning when exists" do + memory_screen = MemoryWarningScreenSelfImplemented.new + memory_screen.memory_warning_from_uikit.should.be.nil + memory_screen.didReceiveMemoryWarning + memory_screen.memory_warning_from_uikit.should == true + end + + it "should call super up the chain" do + memory_screen = MemoryWarningNotSoSuperScreen.new + + memory_screen.memory_warning_from_super.should.be.nil + memory_screen.didReceiveMemoryWarning + memory_screen.memory_warning_from_super.should == true + end + + it "should call on_memory_warning when implemented" do + memory_screen = MemoryWarningScreen.new + + memory_screen.memory_warning_from_pm.should.be.nil + memory_screen.didReceiveMemoryWarning + memory_screen.memory_warning_from_pm.should == true end end describe "navigation controller behavior" do