mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-04-23 20:00:52 +08:00
Add in tests for instance based navigation controller functionality
This commit is contained in:
3
app/test_screens/navigation_controller.rb
Normal file
3
app/test_screens/navigation_controller.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class CustomNavigationController < PM::NavigationController
|
||||
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user