diff --git a/src/tabs/test/tabs.spec.js b/src/tabs/test/tabs.spec.js index bf5e2c671c..cd038a026a 100644 --- a/src/tabs/test/tabs.spec.js +++ b/src/tabs/test/tabs.spec.js @@ -513,6 +513,45 @@ describe('tabs', function() { expect(titles().eq(1)).toHaveClass('active'); expect(contents().eq(1)).toHaveClass('active'); })); + + it('should not select tabs when being destroyed', inject(function($controller, $compile, $rootScope){ + var selectList = [], + deselectList = [], + getTab = function(active){ + return { + active: active, + select : function(){ + selectList.push('select'); + }, + deselect : function(){ + deselectList.push('deselect'); + } + }; + }; + + scope = $rootScope.$new(); + scope.tabs = [ + getTab(true), + getTab(false) + ]; + elm = $compile([ + '', + ' ', + ' heading {{index}}', + ' content {{$index}}', + ' ', + '' + ].join('\n'))(scope); + scope.$apply(); + + // The first tab is selected the during the initial $digest. + expect(selectList.length).toEqual(1); + + // Destroy the tabs - we should not trigger selection/deselection any more. + scope.$destroy(); + expect(selectList.length).toEqual(1); + expect(deselectList.length).toEqual(0); + })); }); describe('disabled', function() {