From 41451bcae9b458b60af831ab6bc444607c4d7866 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Fri, 25 Oct 2024 10:03:20 -0500 Subject: [PATCH] Validate event abbreviation --- app/scripts/controllers/eventDetails.js | 5 ++ test/spec/controllers/eventDetails.spec.js | 58 ++++++++++++++-------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/app/scripts/controllers/eventDetails.js b/app/scripts/controllers/eventDetails.js index 0980601e6..a311baf27 100644 --- a/app/scripts/controllers/eventDetails.js +++ b/app/scripts/controllers/eventDetails.js @@ -272,6 +272,11 @@ angular if (_.isEmpty($scope.conference.abbreviation)) { validationErrors.push('Please enter an event abbreviation.'); } + if (/[&"]/.test($scope.conference.abbreviation)) { + validationErrors.push( + 'Please remove double quotes (") and ampersands (&) from the event abbreviation.', + ); + } if ( $scope.conference.abbreviation && diff --git a/test/spec/controllers/eventDetails.spec.js b/test/spec/controllers/eventDetails.spec.js index db2ea0ea3..ee4f28980 100644 --- a/test/spec/controllers/eventDetails.spec.js +++ b/test/spec/controllers/eventDetails.spec.js @@ -268,32 +268,50 @@ describe('Controller: eventDetails', function () { }), ); - it('saveEvent() should validate the Ministry Purpose', () => { - scope.saveEvent(); + describe('saveEvent', () => { + it('should validate the Ministry Purpose', () => { + scope.saveEvent(); - expect(scope.notify.message.toString()).toContain( - 'Please enter Ministry Purpose.', - ); + expect(scope.notify.message.toString()).toContain( + 'Please enter Ministry Purpose.', + ); - expect(scope.notify.message.toString()).not.toContain( - 'Please enter which Event Type', - ); - }); + expect(scope.notify.message.toString()).not.toContain( + 'Please enter which Event Type', + ); + }); - it('saveEvent() should validate the Event Name', () => { - scope.conference.name = 'Men & Women Conference'; - scope.saveEvent(); + it('should validate the Event Name', () => { + scope.conference.name = 'Men & Women Conference'; + scope.saveEvent(); - expect(scope.notify.message.toString()).toContain( - 'Please remove double quotes (") and ampersands (&) from the event name.', - ); + expect(scope.notify.message.toString()).toContain( + 'Please remove double quotes (") and ampersands (&) from the event name.', + ); - scope.conference.name = '"Cru" Conference'; - scope.saveEvent(); + scope.conference.name = '"Cru" Conference'; + scope.saveEvent(); - expect(scope.notify.message.toString()).toContain( - 'Please remove double quotes (") and ampersands (&) from the event name.', - ); + expect(scope.notify.message.toString()).toContain( + 'Please remove double quotes (") and ampersands (&) from the event name.', + ); + }); + + it('should validate the Event Abbreviation', () => { + scope.conference.abbreviation = 'men&women'; + scope.saveEvent(); + + expect(scope.notify.message.toString()).toContain( + 'Please remove double quotes (") and ampersands (&) from the event abbreviation.', + ); + + scope.conference.abbreviation = '"cru"conf'; + scope.saveEvent(); + + expect(scope.notify.message.toString()).toContain( + 'Please remove double quotes (") and ampersands (&) from the event abbreviation.', + ); + }); }); });