diff --git a/hacking/TabBar.js b/hacking/TabBar.js index 14d3e2c2d9..1f4452780b 100644 --- a/hacking/TabBar.js +++ b/hacking/TabBar.js @@ -17,22 +17,18 @@ TabBarItem.prototype = { 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; - for(var i = 0, j = children.length; i < j; i++) { - child = children[i]; - - } + // Set the title to the text content of the tab. + this.title = this.el.innerText.trim(); }, getIcon: function() { + return this.icon; + }, + getTitle: function() { + return this.title; }, setSelected: function(isSelected) { diff --git a/hacking/TabBar.unit.js b/hacking/TabBar.unit.js index 52599cc853..82a9d015e2 100644 --- a/hacking/TabBar.unit.js +++ b/hacking/TabBar.unit.js @@ -3,7 +3,7 @@ describe('TabBar view', function() { beforeEach(function() { element = $('
' + - 'Tab 1' + + ' Tab 1' + 'Tab 2' + 'Tab 3'); @@ -17,9 +17,15 @@ describe('TabBar view', function() { items = tabBar.getItems(); expect(items.length).toEqual(3); - expect(items[0].el.innerText).toEqual('Tab 1'); - expect(items[1].el.innerText).toEqual('Tab 2'); - expect(items[2].el.innerText).toEqual('Tab 3'); + expect(items[0].getTitle()).toEqual('Tab 1'); + expect(items[1].getTitle()).toEqual('Tab 2'); + 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() { @@ -27,11 +33,11 @@ describe('TabBar view', function() { // Track selection object tabBar.setSelectedItem(1); - expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 2'); + expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 2'); tabBar.setSelectedItem(0); - expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 1'); + expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 1'); tabBar.setSelectedItem(2); - expect(tabBar.getSelectedItem().el.innerText).toEqual('Tab 3'); + expect(tabBar.getSelectedItem().getTitle()).toEqual('Tab 3'); // Track class change 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[2].el.classList.contains('active')).toEqual(false); }); + + it('Should set icon', function() { + items = tabBar.getItems(); + + var item = items[0]; + expect(item.getIcon()).toBe(undefined); + }); });