Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

SUP-2754, [Edit Profile] Allow user to hide external links #604

Merged
merged 1 commit into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

});
});