diff --git a/app/directives/external-account/external-links-data.directive.js b/app/directives/external-account/external-links-data.directive.js index e03b3006e..9d3a84c78 100644 --- a/app/directives/external-account/external-links-data.directive.js +++ b/app/directives/external-account/external-links-data.directive.js @@ -25,6 +25,14 @@ $scope.deletionDialog = null; $scope.confirmDeletion = function(account) { + // for non weblink provider, do nothing + if (account.provider !== 'weblink') { + return; + } + // do nothing for pending state cards + if (account.status === 'PENDING') { + return; + } $scope.deletionDialog = ngDialog.open({ className: 'ngdialog-theme-default tc-dialog', template: 'directives/external-account/external-link-deletion-confirm.html', diff --git a/app/directives/external-account/external-links-data.directive.spec.js b/app/directives/external-account/external-links-data.directive.spec.js index 76592c65e..df3fc571b 100644 --- a/app/directives/external-account/external-links-data.directive.spec.js +++ b/app/directives/external-account/external-links-data.directive.spec.js @@ -103,18 +103,42 @@ describe('External Links Data Directive', function() { expect(element.isolateScope().linkedAccountsData).to.have.length(8); }); - it('should mark the account for deletion and open the popup ', function() { - var account = {key: 'somekey', provider: 'stackoverflow'}; + it('should open the confirmation popup ', function() { + var account = {key: 'somekey', provider: 'weblink'}; element.isolateScope().confirmDeletion(account); scope.$digest(); // should open the popup expect(ngDialogSvc.open).to.be.called; - // should not remove anythign from the array of accounts/links + // should not remove anything from the array of accounts/links expect(element.isolateScope().linkedAccountsData).to.have.length(8); // $scope.deletionDialog should exist expect(element.isolateScope().deletionDialog).to.exist; ngDialogSvc.close(); }); + it('should NOT open the popup for pending state card ', function() { + var account = {key: 'somekey', provider: 'weblink', status: 'PENDING'}; + element.isolateScope().confirmDeletion(account); + scope.$digest(); + // should NOT open the popup + expect(ngDialogSvc.open).not.to.be.called; + // should not remove anything from the array of accounts/links + expect(element.isolateScope().linkedAccountsData).to.have.length(8); + // $scope.deletionDialog should not exist + expect(element.isolateScope().deletionDialog).not.to.exist; + }); + + it('should NOT open the popup for non weblink external link ', function() { + var account = {key: 'somekey', provider: 'stackoverflow'}; + element.isolateScope().confirmDeletion(account); + scope.$digest(); + // should NOT open the popup + expect(ngDialogSvc.open).not.to.be.called; + // should not remove anything from the array of accounts/links + expect(element.isolateScope().linkedAccountsData).to.have.length(8); + // $scope.deletionDialog should not exist + expect(element.isolateScope().deletionDialog).not.to.exist; + }); + }); });