mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Title test working
This commit is contained in:
@ -17,22 +17,18 @@ TabBarItem.prototype = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the title to the text content of the tab.
|
|
||||||
this.title = child.innerText.trim();
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
setIcon: function(iconClass) {
|
|
||||||
var child, children = this.el.children;
|
|
||||||
|
|
||||||
var hasIcon = false;
|
// Set the title to the text content of the tab.
|
||||||
for(var i = 0, j = children.length; i < j; i++) {
|
this.title = this.el.innerText.trim();
|
||||||
child = children[i];
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getIcon: function() {
|
getIcon: function() {
|
||||||
|
return this.icon;
|
||||||
|
},
|
||||||
|
|
||||||
|
getTitle: function() {
|
||||||
|
return this.title;
|
||||||
},
|
},
|
||||||
|
|
||||||
setSelected: function(isSelected) {
|
setSelected: function(isSelected) {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('TabBar view', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
element = $('<div class="tabs">' +
|
element = $('<div class="tabs">' +
|
||||||
'<a href="#" class="tab-item">Tab 1</a>' +
|
'<a href="#" class="tab-item"><i class="icon-home"></i> Tab 1</a>' +
|
||||||
'<a href="#" class="tab-item">Tab 2</a>' +
|
'<a href="#" class="tab-item">Tab 2</a>' +
|
||||||
'<a href="#" class="tab-item">Tab 3</a>');
|
'<a href="#" class="tab-item">Tab 3</a>');
|
||||||
|
|
||||||
@ -17,9 +17,15 @@ describe('TabBar view', function() {
|
|||||||
items = tabBar.getItems();
|
items = tabBar.getItems();
|
||||||
|
|
||||||
expect(items.length).toEqual(3);
|
expect(items.length).toEqual(3);
|
||||||
expect(items[0].el.innerText).toEqual('Tab 1');
|
expect(items[0].getTitle()).toEqual('Tab 1');
|
||||||
expect(items[1].el.innerText).toEqual('Tab 2');
|
expect(items[1].getTitle()).toEqual('Tab 2');
|
||||||
expect(items[2].el.innerText).toEqual('Tab 3');
|
expect(items[2].getTitle()).toEqual('Tab 3');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should trim title', function() {
|
||||||
|
expect(items[0].el.innerText.trim()).toEqual(items[0].getTitle());
|
||||||
|
expect(items[1].el.innerText.trim()).toEqual(items[1].getTitle());
|
||||||
|
expect(items[2].el.innerText.trim()).toEqual(items[2].getTitle());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should select', function() {
|
it('Should select', function() {
|
||||||
@ -27,11 +33,11 @@ describe('TabBar view', function() {
|
|||||||
|
|
||||||
// Track selection object
|
// Track selection object
|
||||||
tabBar.setSelectedItem(1);
|
tabBar.setSelectedItem(1);
|
||||||
expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 2');
|
expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 2');
|
||||||
tabBar.setSelectedItem(0);
|
tabBar.setSelectedItem(0);
|
||||||
expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 1');
|
expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 1');
|
||||||
tabBar.setSelectedItem(2);
|
tabBar.setSelectedItem(2);
|
||||||
expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 3');
|
expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 3');
|
||||||
|
|
||||||
// Track class change
|
// Track class change
|
||||||
expect(tabBar.getSelectedItem().el.classList.contains('active')).toEqual(true);
|
expect(tabBar.getSelectedItem().el.classList.contains('active')).toEqual(true);
|
||||||
@ -46,4 +52,11 @@ describe('TabBar view', function() {
|
|||||||
expect(items[1].el.classList.contains('active')).toEqual(false);
|
expect(items[1].el.classList.contains('active')).toEqual(false);
|
||||||
expect(items[2].el.classList.contains('active')).toEqual(false);
|
expect(items[2].el.classList.contains('active')).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should set icon', function() {
|
||||||
|
items = tabBar.getItems();
|
||||||
|
|
||||||
|
var item = items[0];
|
||||||
|
expect(item.getIcon()).toBe(undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user