@@ -24,7 +24,7 @@ describe('tabs', function() {
2424 }
2525 }
2626
27-
27+
2828 describe ( 'basics' , function ( ) {
2929
3030 beforeEach ( inject ( function ( $compile , $rootScope ) {
@@ -33,14 +33,16 @@ describe('tabs', function() {
3333 scope . second = '2' ;
3434 scope . actives = { } ;
3535 scope . selectFirst = jasmine . createSpy ( ) ;
36- scope . selectSecond = jasmine . createSpy ( ) ;
36+ scope . selectSecond = jasmine . createSpy ( ) ;
37+ scope . deselectFirst = jasmine . createSpy ( ) ;
38+ scope . deselectSecond = jasmine . createSpy ( ) ;
3739 elm = $compile ( [
3840 '<div>' ,
3941 ' <tabset class="hello" data-pizza="pepperoni">' ,
40- ' <tab heading="First Tab {{first}}" active="actives.one" select="selectFirst()">' ,
42+ ' <tab heading="First Tab {{first}}" active="actives.one" select="selectFirst()" deselect="deselectFirst()" >' ,
4143 ' first content is {{first}}' ,
4244 ' </tab>' ,
43- ' <tab active="actives.two" select="selectSecond()">' ,
45+ ' <tab active="actives.two" select="selectSecond()" deselect="deselectSecond()" >' ,
4446 ' <tab-heading><b>Second</b> Tab {{second}}</tab-heading>' ,
4547 ' second content is {{second}}' ,
4648 ' </tab>' ,
@@ -90,6 +92,14 @@ describe('tabs', function() {
9092 expect ( scope . selectFirst ) . toHaveBeenCalled ( ) ;
9193 } ) ;
9294
95+ it ( 'should call deselect callback on deselect' , function ( ) {
96+ titles ( ) . eq ( 1 ) . find ( 'a' ) . click ( ) ;
97+ titles ( ) . eq ( 0 ) . find ( 'a' ) . click ( ) ;
98+ expect ( scope . deselectSecond ) . toHaveBeenCalled ( ) ;
99+ titles ( ) . eq ( 1 ) . find ( 'a' ) . click ( ) ;
100+ expect ( scope . deselectFirst ) . toHaveBeenCalled ( ) ;
101+ } ) ;
102+
93103 } ) ;
94104
95105 describe ( 'ng-repeat' , function ( ) {
@@ -208,7 +218,7 @@ describe('tabs', function() {
208218 expect ( heading ( ) . eq ( 2 ) . text ( ) ) . toBe ( '2' ) ;
209219 expect ( heading ( ) . eq ( 3 ) . text ( ) ) . toBe ( '3' ) ;
210220 } ) ;
211-
221+
212222 } ) ;
213223
214224 //Tests that http://git.io/lG6I9Q is fixed
0 commit comments