Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit f15bfcf

Browse files
Coridynchrisirhc
authored andcommitted
test(tabs): don't select tabs when being destroyed
Closes #2763
1 parent 9939867 commit f15bfcf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: src/tabs/test/tabs.spec.js

+39
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,45 @@ describe('tabs', function() {
513513
expect(titles().eq(1)).toHaveClass('active');
514514
expect(contents().eq(1)).toHaveClass('active');
515515
}));
516+
517+
it('should not select tabs when being destroyed', inject(function($controller, $compile, $rootScope){
518+
var selectList = [],
519+
deselectList = [],
520+
getTab = function(active){
521+
return {
522+
active: active,
523+
select : function(){
524+
selectList.push('select');
525+
},
526+
deselect : function(){
527+
deselectList.push('deselect');
528+
}
529+
};
530+
};
531+
532+
scope = $rootScope.$new();
533+
scope.tabs = [
534+
getTab(true),
535+
getTab(false)
536+
];
537+
elm = $compile([
538+
'<tabset>',
539+
' <tab ng-repeat="t in tabs" active="t.active" select="t.select()" deselect="t.deselect()">',
540+
' <tab-heading><b>heading</b> {{index}}</tab-heading>',
541+
' content {{$index}}',
542+
' </tab>',
543+
'</tabset>'
544+
].join('\n'))(scope);
545+
scope.$apply();
546+
547+
// The first tab is selected the during the initial $digest.
548+
expect(selectList.length).toEqual(1);
549+
550+
// Destroy the tabs - we should not trigger selection/deselection any more.
551+
scope.$destroy();
552+
expect(selectList.length).toEqual(1);
553+
expect(deselectList.length).toEqual(0);
554+
}));
516555
});
517556

518557
describe('disabled', function() {

0 commit comments

Comments
 (0)