Skip to content

Commit

Permalink
Only expose giving links to national staff (#1073)
Browse files Browse the repository at this point in the history
* Only expose giving links to national staff

* Avoid var
  • Loading branch information
canac authored Nov 8, 2023
1 parent 0d56166 commit 09256f4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ModalInstanceCtrl {
this.givingLinks = sortBy(this.givingLinks, 'order')

this.tab = 'newsletter'
this.givingLinksAvailable = designationType === 'National Staff'
}

transformGivingLinks () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import module from './personalOptions.modal'

describe('Designation Editor Personal Options', function () {
beforeEach(angular.mock.module(module.name))
var $ctrl
let $ctrl

const controllerInjections = {
designationNumber: '000555',
designationType: 'Staff',
giveDomain: 'https://give.cru.org',
givingLinks: {
'jcr:primaryType': 'nt:unstructured',
1: { 'jcr:primaryType': 'nt:unstructured', url: 'https://example.com', name: 'Name' }
},
showNewsletterForm: true,
hasNewsletter: true,
}

beforeEach(inject(function ($rootScope, $controller) {
const $scope = $rootScope.$new()

$ctrl = $controller(module.name, {
designationNumber: '000555',
designationType: 'Staff',
giveDomain: 'https://give.cru.org',
givingLinks: {
'jcr:primaryType': 'nt:unstructured',
1: { 'jcr:primaryType': 'nt:unstructured', url: 'https://example.com', name: 'Name' }
},
showNewsletterForm: true,
hasNewsletter: true,
...controllerInjections,
$scope: $scope
})
$scope.$close = jest.fn()
Expand All @@ -41,6 +45,28 @@ describe('Designation Editor Personal Options', function () {
})
})

describe('givingLinksAvailable', () => {
describe('for national staff', () => {
beforeEach(inject(function ($rootScope, $controller) {
const $scope = $rootScope.$new()

$ctrl = $controller(module.name, {
...controllerInjections,
designationType: 'National Staff',
$scope: $scope
})
}))

it('is true', () => {
expect($ctrl.givingLinksAvailable).toBe(true)
})
})

it('otherwise is false', () => {
expect($ctrl.givingLinksAvailable).toBe(false)
})
})

describe('saveChanges()', () => {
it('should close modal and provide updated properties', () => {
$ctrl.showNewsletterForm = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a href="" ng-click="$ctrl.tab = 'newsletter'">
MPDX Newsletter <span class="xs-hide">Form</span>
</a>
<a href="" ng-click="$ctrl.tab = 'givingLinks'">
<a href="" ng-click="$ctrl.tab = 'givingLinks'" ng-if="$ctrl.givingLinksAvailable">
Giving Links
</a>
</li>
Expand Down

0 comments on commit 09256f4

Please sign in to comment.