Add in tests for instance based navigation controller functionality

This commit is contained in:
Jon Morehouse
2014-06-29 15:44:13 -07:00
parent 4957d946af
commit 6964315409
3 changed files with 13 additions and 3 deletions

View File

@@ -0,0 +1,3 @@
class CustomNavigationController < PM::NavigationController
end

View File

@@ -44,7 +44,7 @@ module ProMotion
def add_nav_bar(args = {})
self.navigationController ||= begin
self.first_screen = true if self.respond_to?(:first_screen=)
nav = NavigationController.alloc.initWithRootViewController(self)
nav = (args[:nav_controller] || NavigationController).alloc.initWithRootViewController(self)
nav.setModalTransitionStyle(args[:transition_style]) if args[:transition_style]
nav.setModalPresentationStyle(args[:presentation_style]) if args[:presentation_style]
nav

View File

@@ -125,14 +125,20 @@ describe "screen properties" do
describe "navigation controller behavior" do
it "should have a nav bar" do
@screen.nav_bar?.should == true
it "should let the instance set the nav_controller" do
screen = HomeScreen.new nav_bar: true, nav_controller: CustomNavigationController
screen.on_load
screen.navigationController.should.be.instance_of CustomNavigationController
end
it "#navigationController should return a navigation controller" do
@screen.navigationController.should.be.instance_of ProMotion::NavigationController
end
it "should have a nav bar" do
@screen.nav_bar?.should == true
end
it "have a right bar button item" do
@screen.navigationItem.rightBarButtonItem.should.not == nil
end
@@ -260,4 +266,5 @@ describe "screen with toolbar" do
screen.set_toolbar_button([{title: "Testing Toolbar"}], false)
screen.navigationController.toolbarHidden?.should == false
end
end