@@ -73,7 +73,7 @@ describe('tabs', function() {
73
73
expect ( titles ( ) . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
74
74
expect ( titles ( ) . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
75
75
expect ( scope . actives . one ) . toBe ( true ) ;
76
- expect ( scope . actives . two ) . toBe ( false ) ;
76
+ expect ( scope . actives . two ) . toBeFalsy ( ) ;
77
77
} ) ;
78
78
79
79
it ( 'should change active on click' , function ( ) {
@@ -99,7 +99,6 @@ describe('tabs', function() {
99
99
titles ( ) . eq ( 1 ) . find ( 'a' ) . click ( ) ;
100
100
expect ( scope . deselectFirst ) . toHaveBeenCalled ( ) ;
101
101
} ) ;
102
-
103
102
} ) ;
104
103
105
104
describe ( 'basics with initial active tab' , function ( ) {
@@ -153,6 +152,48 @@ describe('tabs', function() {
153
152
} ) ;
154
153
} ) ;
155
154
155
+ describe ( 'tab callback order' , function ( ) {
156
+ var execOrder ;
157
+ beforeEach ( inject ( function ( $compile , $rootScope ) {
158
+ scope = $rootScope . $new ( ) ;
159
+ execOrder = [ ] ;
160
+ scope . actives = { } ;
161
+
162
+ scope . execute = function ( id ) {
163
+ execOrder . push ( id ) ;
164
+ } ;
165
+
166
+ elm = $compile ( [
167
+ '<div>' ,
168
+ ' <tabset class="hello" data-pizza="pepperoni">' ,
169
+ ' <tab heading="First Tab" active="actives.one" select="execute(\'select1\')" deselect="execute(\'deselect1\')"></tab>' ,
170
+ ' <tab select="execute(\'select2\')" deselect="execute(\'deselect2\')"></tab>' ,
171
+ ' </tabset>' ,
172
+ '</div>'
173
+ ] . join ( '\n' ) ) ( scope ) ;
174
+ scope . $apply ( ) ;
175
+ return elm ;
176
+ } ) ) ;
177
+
178
+ it ( 'should call select for the first tab' , function ( ) {
179
+ expect ( execOrder ) . toEqual ( [ 'select1' ] ) ;
180
+ } ) ;
181
+
182
+ it ( 'should call deselect, then select' , function ( ) {
183
+ execOrder = [ ] ;
184
+
185
+ // Select second tab
186
+ titles ( ) . eq ( 1 ) . find ( 'a' ) . click ( ) ;
187
+ expect ( execOrder ) . toEqual ( [ 'deselect1' , 'select2' ] ) ;
188
+
189
+ execOrder = [ ] ;
190
+
191
+ // Select again first tab
192
+ titles ( ) . eq ( 0 ) . find ( 'a' ) . click ( ) ;
193
+ expect ( execOrder ) . toEqual ( [ 'deselect2' , 'select1' ] ) ;
194
+ } ) ;
195
+ } ) ;
196
+
156
197
describe ( 'ng-repeat' , function ( ) {
157
198
158
199
beforeEach ( inject ( function ( $compile , $rootScope ) {
@@ -346,7 +387,11 @@ describe('tabs', function() {
346
387
347
388
describe ( 'tabset controller' , function ( ) {
348
389
function mockTab ( isActive ) {
349
- return { active : ! ! isActive } ;
390
+ return {
391
+ active : ! ! isActive ,
392
+ onSelect : angular . noop ,
393
+ onDeselect : angular . noop
394
+ } ;
350
395
}
351
396
352
397
var ctrl ;
0 commit comments