@@ -154,7 +154,7 @@ describe('uib-accordion', function() {
154
154
} ) ;
155
155
156
156
describe ( 'uib-accordion-group' , function ( ) {
157
- var scope , $compile ;
157
+ var scope , $compile , $animate ;
158
158
var element , groups ;
159
159
var findGroupHeading = function ( index ) {
160
160
return groups . eq ( index ) . find ( '.panel-heading' ) . eq ( 0 ) ;
@@ -166,9 +166,10 @@ describe('uib-accordion', function() {
166
166
return groups . eq ( index ) . find ( '.panel-collapse' ) . eq ( 0 ) ;
167
167
} ;
168
168
169
- beforeEach ( inject ( function ( _$rootScope_ , _$compile_ ) {
169
+ beforeEach ( inject ( function ( _$rootScope_ , _$compile_ , _$animate_ ) {
170
170
scope = _$rootScope_ ;
171
171
$compile = _$compile_ ;
172
+ $animate = _$animate_ ;
172
173
} ) ) ;
173
174
174
175
it ( 'should allow custom templates' , inject ( function ( $templateCache ) {
@@ -620,5 +621,53 @@ describe('uib-accordion', function() {
620
621
expect ( findGroupLink ( 0 ) . text ( ) ) . toBe ( 'baz' ) ;
621
622
} ) ) ;
622
623
} ) ;
624
+
625
+ describe ( 'event' , function ( ) {
626
+ beforeEach ( function ( ) {
627
+ var tpl =
628
+ '<uib-accordion>' +
629
+ '<div uib-accordion-group heading="A heading" expanding="expanding()" expanded="expanded()" collapsed="collapsed()" collapsing="collapsing()">' +
630
+ 'Body' +
631
+ '</div>' +
632
+ '</uib-accordion>' ;
633
+ element = $compile ( tpl ) ( scope ) ;
634
+ scope . $digest ( ) ;
635
+ groups = element . find ( '.panel' ) ;
636
+ } ) ;
637
+
638
+ it ( 'on expanding is triggered' , function ( ) {
639
+ scope . expanding = function ( ) { } ;
640
+ spyOn ( scope , 'expanding' ) ;
641
+ findGroupLink ( 0 ) . click ( ) ;
642
+ expect ( scope . expanding ) . toHaveBeenCalled ( ) ;
643
+ } ) ;
644
+
645
+ it ( 'on expanded is triggered' , function ( ) {
646
+ scope . expanded = function ( ) { } ;
647
+ spyOn ( scope , 'expanded' ) ;
648
+ findGroupLink ( 0 ) . click ( ) ;
649
+ $animate . flush ( ) ;
650
+ expect ( scope . expanded ) . toHaveBeenCalled ( ) ;
651
+ } ) ;
652
+
653
+ it ( 'on collapsed is triggered' , function ( ) {
654
+ scope . collapsed = function ( ) { } ;
655
+ spyOn ( scope , 'collapsed' ) ;
656
+ findGroupLink ( 0 ) . click ( ) ;
657
+ findGroupLink ( 0 ) . click ( ) ;
658
+ expect ( scope . collapsed ) . toHaveBeenCalled ( ) ;
659
+ } ) ;
660
+
661
+ it ( 'on collapsing is triggered' , function ( ) {
662
+ scope . collapsing = function ( ) { } ;
663
+ spyOn ( scope , 'collapsing' ) ;
664
+ findGroupLink ( 0 ) . click ( ) ;
665
+ $animate . flush ( ) ;
666
+ findGroupLink ( 0 ) . click ( ) ;
667
+ expect ( scope . collapsing ) . toHaveBeenCalled ( ) ;
668
+ } ) ;
669
+
670
+ } ) ;
671
+
623
672
} ) ;
624
673
} ) ;
0 commit comments