mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Fixed tests and removed DOM call from TabBarController
This commit is contained in:
@ -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) {
|
trySelectItem: function(item) {
|
||||||
for(var i = 0, j = this.items.length; i < j; i += 1) {
|
for(var i = 0, j = this.items.length; i < j; i += 1) {
|
||||||
if(this.items[i] == item) {
|
if(this.items[i] == item) {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ describe('TabBar view', function() {
|
|||||||
|
|
||||||
it('Should handle item click event', function() {
|
it('Should handle item click event', function() {
|
||||||
var item = items[0];
|
var item = items[0];
|
||||||
spyOn(tabBar, 'selectItem');
|
spyOn(tabBar, 'trySelectItem');
|
||||||
|
|
||||||
var event = new CustomEvent('tap', {
|
var event = new CustomEvent('tap', {
|
||||||
target: item.el
|
target: item.el
|
||||||
@ -60,7 +60,7 @@ describe('TabBar view', function() {
|
|||||||
item.el.dispatchEvent(event);
|
item.el.dispatchEvent(event);
|
||||||
|
|
||||||
//expect(item.onTap).toHaveBeenCalled();
|
//expect(item.onTap).toHaveBeenCalled();
|
||||||
expect(tabBar.selectItem).toHaveBeenCalled();
|
expect(tabBar.trySelectItem).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -59,11 +59,11 @@ TabBarController.prototype = {
|
|||||||
|
|
||||||
for(var i = 0, j = this.controllers.length; i < j; i ++) {
|
for(var i = 0, j = this.controllers.length; i < j; i ++) {
|
||||||
c = this.controllers[i];
|
c = this.controllers[i];
|
||||||
c.el.style.display = 'none';
|
c.detach && c.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
c = this.controllers[index];
|
c = this.controllers[index];
|
||||||
c.el.style.display = 'block';
|
c.attach && c.attach();
|
||||||
},
|
},
|
||||||
|
|
||||||
_clearSelected: function() {
|
_clearSelected: function() {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ describe('TabBarController', function() {
|
|||||||
it('Should add Controllers', function() {
|
it('Should add Controllers', function() {
|
||||||
ctrl.addController({
|
ctrl.addController({
|
||||||
title: 'Item 1',
|
title: 'Item 1',
|
||||||
icon: 'icon-home'
|
icon: 'icon-home',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(ctrl.getController(0).title).toEqual('Item 1');
|
expect(ctrl.getController(0).title).toEqual('Item 1');
|
||||||
|
|||||||
Reference in New Issue
Block a user