Files
ProMotion/spec/functional/func_tab_bar_spec.rb
Jamon Holmgren cb88e225fe Tab bar refactor
* Fixes issue #167
* Added PM::TabBarController
* Moved some PM::Tab methods into PM::TabBarController
* Moved some tab-related accessors into PM::Tab
* Allowed `open_tab` from AppDelegate and on the PM::TabBarController
directly
* Added tests
* Added a method: set_tab_bar_badge(number)
* Also fixed an error in the cell identifier creation code that was
creating too many identifiers

75 specifications (144 requirements), 0 failures, 0 errors
2013-06-28 11:58:05 -07:00

79 lines
2.4 KiB
Ruby

describe "PM::Tabs" do
tests PM::Tabs
# Override controller to properly instantiate
def controller
@app ||= TestDelegate.new
@screen1 = BasicScreen.new(nav_bar: true, title: "Screen 1")
@screen2 = BasicScreen.new(nav_bar: true, title: "Screen 2")
@screen3 = BasicScreen.new(title: "Screen 3")
@screen4 = BasicScreen.new(title: "Screen 4")
@controller ||= @app.open_tab_bar(@screen1, @screen2, @screen3, @screen4)
@tab_bar = @controller
end
it "should create a UITabBarController" do
@app.window.rootViewController.should.be.kind_of UITabBarController
end
it "should have four tabs" do
@tab_bar.viewControllers.length.should == 4
end
it "should have the right screens in the right places" do
@tab_bar.viewControllers[0].should == @screen1.navigationController
@tab_bar.viewControllers[1].should == @screen2.navigationController
@tab_bar.viewControllers[2].should == @screen3
@tab_bar.viewControllers[3].should == @screen4
end
it "should allow opening a tab by the name from any screen" do
@screen1.open_tab "Screen 2"
@tab_bar.selectedIndex.should == 1
@screen2.open_tab "Screen 3"
@tab_bar.selectedIndex.should == 2
@screen3.open_tab "Screen 4"
@tab_bar.selectedIndex.should == 3
@screen4.open_tab "Screen 1"
@tab_bar.selectedIndex.should == 0
end
it "should allow opening a tab by the index from any screen" do
@screen1.open_tab 1
@tab_bar.selectedIndex.should == 1
@screen2.open_tab 2
@tab_bar.selectedIndex.should == 2
@screen3.open_tab 3
@tab_bar.selectedIndex.should == 3
@screen4.open_tab 0
@tab_bar.selectedIndex.should == 0
end
it "should allow opening a tab from the app_delegate" do
@app.open_tab "Screen 2"
@tab_bar.selectedIndex.should == 1
@app.open_tab "Screen 3"
@tab_bar.selectedIndex.should == 2
@app.open_tab "Screen 4"
@tab_bar.selectedIndex.should == 3
@app.open_tab "Screen 1"
@tab_bar.selectedIndex.should == 0
end
it "should allow opening a tab by accessing the tab bar directly" do
@tab_bar.open_tab "Screen 2"
@tab_bar.selectedIndex.should == 1
@tab_bar.open_tab "Screen 3"
@tab_bar.selectedIndex.should == 2
@tab_bar.open_tab "Screen 4"
@tab_bar.selectedIndex.should == 3
@tab_bar.open_tab "Screen 1"
@tab_bar.selectedIndex.should == 0
end
end