Fixed tests and removed DOM call from TabBarController

This commit is contained in:
Max Lynch
2013-09-16 11:26:54 -05:00
parent 6c32a638ad
commit 61125473de
4 changed files with 8 additions and 5 deletions

View File

@ -148,6 +148,9 @@ TabBar.prototype = {
}
},
// Try to select a given item. This triggers an event such
// that the view controller managing this tab bar can decide
// whether to select the item or cancel it.
trySelectItem: function(item) {
for(var i = 0, j = this.items.length; i < j; i += 1) {
if(this.items[i] == item) {

View File

@ -52,7 +52,7 @@ describe('TabBar view', function() {
it('Should handle item click event', function() {
var item = items[0];
spyOn(tabBar, 'selectItem');
spyOn(tabBar, 'trySelectItem');
var event = new CustomEvent('tap', {
target: item.el
@ -60,7 +60,7 @@ describe('TabBar view', function() {
item.el.dispatchEvent(event);
//expect(item.onTap).toHaveBeenCalled();
expect(tabBar.selectItem).toHaveBeenCalled();
expect(tabBar.trySelectItem).toHaveBeenCalled();
});

View File

@ -59,11 +59,11 @@ TabBarController.prototype = {
for(var i = 0, j = this.controllers.length; i < j; i ++) {
c = this.controllers[i];
c.el.style.display = 'none';
c.detach && c.detach();
}
c = this.controllers[index];
c.el.style.display = 'block';
c.attach && c.attach();
},
_clearSelected: function() {

View File

@ -11,7 +11,7 @@ describe('TabBarController', function() {
it('Should add Controllers', function() {
ctrl.addController({
title: 'Item 1',
icon: 'icon-home'
icon: 'icon-home',
});
expect(ctrl.getController(0).title).toEqual('Item 1');