Skip to content

Commit

Permalink
test(tabs): don't select tabs when being destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
Coridyn authored and Oron Nadiv committed Nov 18, 2014
1 parent 4d77f39 commit d1cf9de
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 d1cf9de

Please sign in to comment.