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

Commit

Permalink
test(tabs): don't select tabs when being destroyed
Browse files Browse the repository at this point in the history
Closes #2763
  • Loading branch information
Coridyn authored and chrisirhc committed Oct 1, 2014
1 parent 9939867 commit f15bfcf
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
'<tabset>',
' <tab ng-repeat="t in tabs" active="t.active" select="t.select()" deselect="t.deselect()">',
' <tab-heading><b>heading</b> {{index}}</tab-heading>',
' content {{$index}}',
' </tab>',
'</tabset>'
].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() {
Expand Down

0 comments on commit f15bfcf

Please sign in to comment.