Skip to content

Commit

Permalink
Validate event abbreviation
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Oct 25, 2024
1 parent 48a5ca2 commit 41451bc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 20 deletions.
5 changes: 5 additions & 0 deletions app/scripts/controllers/eventDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
58 changes: 38 additions & 20 deletions test/spec/controllers/eventDetails.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
});
});
});

Expand Down

0 comments on commit 41451bc

Please sign in to comment.