@@ -2,7 +2,7 @@ describe('Tab Bar Controller', function() {
2
2
var compile , element , scope , ctrl ;
3
3
4
4
beforeEach ( module ( 'ionic.ui.tabs' ) ) ;
5
-
5
+
6
6
beforeEach ( inject ( function ( $compile , $rootScope , $controller ) {
7
7
compile = $compile ;
8
8
scope = $rootScope ;
@@ -63,20 +63,20 @@ describe('Tab Bar Controller', function() {
63
63
64
64
describe ( 'Tabs directive' , function ( ) {
65
65
var compile , element , scope ;
66
-
66
+
67
67
beforeEach ( module ( 'ionic.ui.tabs' ) ) ;
68
68
69
69
beforeEach ( inject ( function ( $compile , $rootScope ) {
70
70
compile = $compile ;
71
71
scope = $rootScope ;
72
72
} ) ) ;
73
-
73
+
74
74
it ( 'Has tab class' , function ( ) {
75
75
element = compile ( '<tabs></tabs>' ) ( scope ) ;
76
76
scope . $digest ( ) ;
77
77
expect ( element . find ( '.tabs' ) . hasClass ( 'tabs' ) ) . toBe ( true ) ;
78
78
} ) ;
79
-
79
+
80
80
it ( 'Has tab children' , function ( ) {
81
81
element = compile ( '<tabs></tabs>' ) ( scope ) ;
82
82
scope = element . scope ( ) ;
@@ -90,18 +90,18 @@ describe('Tabs directive', function() {
90
90
} ) ;
91
91
92
92
it ( 'Has compiled children' , function ( ) {
93
- element = compile ( '<tabs>' +
94
- '<tab active="true" title="Item" icon="icon-default"></tab>' +
95
- '<tab active="true" title="Item" icon="icon-default"></tab>' +
93
+ element = compile ( '<tabs>' +
94
+ '<tab active="true" title="Item" icon="icon-default"></tab>' +
95
+ '<tab active="true" title="Item" icon="icon-default"></tab>' +
96
96
'</tabs>' ) ( scope ) ;
97
97
scope . $digest ( ) ;
98
98
expect ( element . find ( 'a' ) . length ) . toBe ( 2 ) ;
99
99
} ) ;
100
100
101
101
it ( 'Sets style on child tabs' , function ( ) {
102
- element = compile ( '<tabs tabs-type="tabs-positive" tabs-style="tabs-icon-bottom">' +
103
- '<tab active="true" title="Item" icon="icon-default"></tab>' +
104
- '<tab active="true" title="Item" icon="icon-default"></tab>' +
102
+ element = compile ( '<tabs tabs-type="tabs-positive" tabs-style="tabs-icon-bottom">' +
103
+ '<tab active="true" title="Item" icon="icon-default"></tab>' +
104
+ '<tab active="true" title="Item" icon="icon-default"></tab>' +
105
105
'</tabs>' ) ( scope ) ;
106
106
scope . $digest ( ) ;
107
107
var tabs = element [ 0 ] . querySelector ( '.tabs' ) ;
@@ -110,9 +110,9 @@ describe('Tabs directive', function() {
110
110
} ) ;
111
111
112
112
it ( 'Has nav-view' , function ( ) {
113
- element = compile ( '<tabs>' +
114
- '<tab active="true" title="Item 1" href="#/page1"><nav-view name="name1"></nav-view></tab>' +
115
- '<tab active="true" title="Item 2" href="/page2">content2</tab>' +
113
+ element = compile ( '<tabs>' +
114
+ '<tab active="true" title="Item 1" href="#/page1"><nav-view name="name1"></nav-view></tab>' +
115
+ '<tab active="true" title="Item 2" href="/page2">content2</tab>' +
116
116
'</tabs>' ) ( scope ) ;
117
117
scope = element . scope ( ) ;
118
118
scope . $digest ( ) ;
@@ -129,7 +129,7 @@ describe('Tabs directive', function() {
129
129
130
130
describe ( 'Tab Item directive' , function ( ) {
131
131
var compile , element , scope , ctrl ;
132
-
132
+
133
133
beforeEach ( module ( 'ionic.ui.tabs' ) ) ;
134
134
135
135
beforeEach ( inject ( function ( $compile , $rootScope , $document , $controller ) {
@@ -138,23 +138,16 @@ describe('Tab Item directive', function() {
138
138
139
139
scope . badgeValue = 3 ;
140
140
element = compile ( '<tabs>' +
141
- '<tab title="Item" icon="icon-default" badge="badgeValue"></tab>' +
141
+ '<tab title="Item" icon="icon-default" badge="badgeValue"></tab>' +
142
142
'</tabs>' ) ( scope ) ;
143
143
scope . $digest ( ) ;
144
144
$document [ 0 ] . body . appendChild ( element [ 0 ] ) ;
145
145
} ) ) ;
146
-
147
- it ( 'Default text works' , function ( ) {
148
- var title = '' ;
149
- var a = element . find ( 'a' ) [ 0 ] ;
150
- for ( i = 0 , j = a . childNodes . length ; i < j ; i ++ ) {
151
- child = a . childNodes [ i ] ;
152
146
153
- if ( child . nodeName === "#text" ) {
154
- title += child . nodeValue . trim ( ) ;
155
- }
156
- }
157
- expect ( title ) . toEqual ( 'Item' ) ;
147
+ it ( 'Title works' , function ( ) {
148
+ //The badge's text gets in the way of just doing .text() on the element itself, so exclude it
149
+ var notBadge = angular . element ( element [ 0 ] . querySelectorAll ( 'a >:not(.badge)' ) ) ;
150
+ expect ( notBadge . text ( ) . trim ( ) ) . toEqual ( 'Item' ) ;
158
151
} ) ;
159
152
160
153
it ( 'Default icon works' , function ( ) {
@@ -189,7 +182,7 @@ describe('Tab Item directive', function() {
189
182
190
183
describe ( 'Tab Controller Item directive' , function ( ) {
191
184
var compile , element , scope , ctrl ;
192
-
185
+
193
186
beforeEach ( module ( 'ionic.ui.tabs' ) ) ;
194
187
195
188
beforeEach ( inject ( function ( $compile , $rootScope , $document , $controller ) {
@@ -198,24 +191,15 @@ describe('Tab Controller Item directive', function() {
198
191
199
192
scope . badgeValue = 3 ;
200
193
scope . isActive = false ;
201
- element = compile ( '<tabs class="tabs">' +
202
- '<tab-controller-item icon-title="Icon title" icon="icon-class" icon-on="icon-on-class" icon-off="icon-off-class" badge="badgeValue" active="isActive" index="0"></tab-controller-item>' +
194
+ element = compile ( '<tabs class="tabs">' +
195
+ '<tab-controller-item icon-title="Icon <b> title</b> " icon="icon-class" icon-on="icon-on-class" icon-off="icon-off-class" badge="badgeValue" active="isActive" index="0"></tab-controller-item>' +
203
196
'</tabs>' ) ( scope ) ;
204
197
scope . $digest ( ) ;
205
198
$document [ 0 ] . body . appendChild ( element [ 0 ] ) ;
206
199
} ) ) ;
207
-
208
- it ( 'Icon title works' , function ( ) {
209
- var title = '' ;
210
- var a = element . find ( 'a' ) [ 0 ] ;
211
- for ( var i = 0 , j = a . childNodes . length ; i < j ; i ++ ) {
212
- child = a . childNodes [ i ] ;
213
-
214
- if ( child . nodeName === "#text" ) {
215
- title += child . nodeValue . trim ( ) ;
216
- }
217
- }
218
- expect ( title ) . toEqual ( 'Icon title' ) ;
200
+
201
+ it ( 'Icon title works as html' , function ( ) {
202
+ expect ( element . find ( 'a' ) . find ( 'span' ) . html ( ) ) . toEqual ( 'Icon <b>title</b>' ) ;
219
203
} ) ;
220
204
221
205
it ( 'Icon classes works' , function ( ) {
0 commit comments