diff --git a/test/spec/controllers/eventForm.spec.js b/test/spec/controllers/eventForm.spec.js
index c1d879083..02e86562e 100644
--- a/test/spec/controllers/eventForm.spec.js
+++ b/test/spec/controllers/eventForm.spec.js
@@ -128,7 +128,7 @@ describe('Controller: eventForm', function () {
scope.previewForm();
expect($location.path).toHaveBeenCalledWith(
- '/preview/c63b8abf-52ff-4cc4-afbc-5923b01f1ab0/page/',
+ `/preview/${testData.conference.id}/page/`,
);
});
});
@@ -143,7 +143,7 @@ describe('Controller: eventForm', function () {
});
it('refuses to delete pages with an email profile question', () => {
- scope.deletePage('5c69bfcc-9e35-4bd8-8358-fe50fd86052d');
+ scope.deletePage(testData.conference.registrationPages[0].id);
expect(modalMessage.error).toHaveBeenCalledTimes(1);
expect(modalMessage.error.calls.argsFor(0)[0].message).toBe(
@@ -152,7 +152,7 @@ describe('Controller: eventForm', function () {
});
it('refuses to delete pages with a name profile question', () => {
- scope.deletePage('7b4c19df-7377-4d37-90fb-5b262bb66d1a');
+ scope.deletePage(testData.conference.registrationPages[1].id);
expect(modalMessage.error).toHaveBeenCalledTimes(1);
expect(modalMessage.error.calls.argsFor(0)[0].message).toBe(
@@ -161,7 +161,7 @@ describe('Controller: eventForm', function () {
});
it('refuses to delete pages with a waiver profile question', () => {
- scope.deletePage('aee6734c-17c2-4e60-9506-b5670b95367e');
+ scope.deletePage(testData.waiverPage.id);
expect(modalMessage.error).toHaveBeenCalledTimes(1);
expect(modalMessage.error.calls.argsFor(0)[0].message).toBe(
@@ -172,12 +172,10 @@ describe('Controller: eventForm', function () {
it('deletes pages', () => {
spyOn(GrowlService, 'growl');
spyOn(modalMessage, 'confirm').and.returnValue($q.resolve());
- scope.conference.registrationPages[1].blocks =
- scope.conference.registrationPages[1].blocks.filter(
- (block) => block.profileType === null,
- );
+ const page = scope.conference.registrationPages[1];
+ page.blocks = page.blocks.filter((block) => block.profileType === null);
- scope.deletePage('7b4c19df-7377-4d37-90fb-5b262bb66d1a', true);
+ scope.deletePage(page.id, true);
scope.$digest();
expect(modalMessage.confirm).toHaveBeenCalledTimes(1);
@@ -185,7 +183,7 @@ describe('Controller: eventForm', function () {
modalMessage.confirm.calls.argsFor(0)[0].question;
expect(confirmationMessage).toContain(
- 'Are you sure you want to delete Page 2?',
+ `Are you sure you want to delete ${page.title}?`,
);
expect(confirmationMessage).toContain(
@@ -198,7 +196,7 @@ describe('Controller: eventForm', function () {
expect(GrowlService.growl).toHaveBeenCalledTimes(1);
expect(GrowlService.growl.calls.argsFor(0)[3]).toBe(
- 'Page "Page 2" has been deleted.',
+ `Page "${page.title}" has been deleted.`,
);
});
});
@@ -211,7 +209,7 @@ describe('Controller: eventForm', function () {
expect(newBlock.id).not.toBe(existingBlock.id);
expect(newBlock.position).toBe(4);
- expect(newBlock.title).toBe('Dropdown Question (copy)');
+ expect(newBlock.title).toBe(`${existingBlock.title} (copy)`);
expect(newBlock.rules[0].id).not.toBe(existingBlock.rules[0].id);
expect(newBlock.rules[0].blockId).toBe(newBlock.id);
});
@@ -266,14 +264,16 @@ describe('Controller: eventForm', function () {
});
describe('deleteBlock', () => {
+ const block = testData.conference.registrationPages[1].blocks[4];
+
it('deletes a block', () => {
spyOn(GrowlService, 'growl');
- scope.deleteBlock('0b876382-5fd1-46af-b778-10fc9b1b530d', true);
+ scope.deleteBlock(block.id, true);
expect(GrowlService.growl).toHaveBeenCalledTimes(1);
expect(GrowlService.growl.calls.argsFor(0)[3]).toBe(
- '"Multiple Choice Question" has been deleted.',
+ `"${block.title}" has been deleted.`,
);
});
@@ -281,7 +281,7 @@ describe('Controller: eventForm', function () {
spyOn(modalMessage, 'error');
scope.conference.registrationPages.push(testData.rulesPage);
- scope.deleteBlock('0b876382-5fd1-46af-b778-10fc9b1b530d', true);
+ scope.deleteBlock(block.id, true);
expect(modalMessage.error).toHaveBeenCalledTimes(1);
const errorMessage = modalMessage.error.calls.argsFor(0)[0].message;
diff --git a/test/spec/controllers/eventRegistrations.spec.js b/test/spec/controllers/eventRegistrations.spec.js
index 85e11caf6..561f351b5 100644
--- a/test/spec/controllers/eventRegistrations.spec.js
+++ b/test/spec/controllers/eventRegistrations.spec.js
@@ -134,17 +134,17 @@ describe('Controller: eventRegistrations', function () {
describe('toggleColumn', () => {
it('toggles the column visibility', () => {
const setItem = spyOn($window.localStorage, 'setItem');
- scope.toggleColumn(0);
+ const blockIndex = 0;
+ const block = scope.blocks[blockIndex];
+ scope.toggleColumn(blockIndex);
- expect(scope.blocks[0].visible).toBe(true);
+ expect(block.visible).toBe(true);
expect(setItem).toHaveBeenCalledWith(
`visibleBlocks:${testData.conference.id}`,
- '["e088fefc-eb9c-4904-b849-017facc9e063"]',
+ `["${block.id}"]`,
);
- expect(scope.queryParameters.block).toEqual([
- 'e088fefc-eb9c-4904-b849-017facc9e063',
- ]);
+ expect(scope.queryParameters.block).toEqual([block.id]);
scope.toggleColumn(0);
@@ -220,13 +220,17 @@ describe('Controller: eventRegistrations', function () {
});
it('returns the value of simple answers', () => {
- scope.queryParameters.orderBy = '9b83eebd-b064-4edf-92d0-7982a330272a';
+ const answer = testData.registration.registrants[0].answers[0];
+ scope.queryParameters.orderBy = answer.blockId;
- expect(scope.answerSort(testData.registration.registrants[0])).toBe('M');
+ expect(scope.answerSort(testData.registration.registrants[0])).toBe(
+ answer.value,
+ );
});
it('returns the values of complex answers', () => {
- scope.queryParameters.orderBy = '122a15bf-0608-4813-834a-0d31a8c44c64';
+ const answer = testData.registration.registrants[0].answers[6];
+ scope.queryParameters.orderBy = answer.blockId;
expect(scope.answerSort(testData.registration.registrants[0])).toBe(
'Test,Person',
@@ -234,7 +238,8 @@ describe('Controller: eventRegistrations', function () {
});
it('returns the keys of checkbox answers', () => {
- scope.queryParameters.orderBy = '18ccfb09-3006-4981-ab5e-405ccf2aad1c';
+ const answer = testData.registration.registrants[0].answers[4];
+ scope.queryParameters.orderBy = answer.blockId;
expect(scope.answerSort(testData.registration.registrants[0])).toBe(
'651',
@@ -543,15 +548,16 @@ describe('Controller: eventRegistrations', function () {
it('deletes a registrant in a group', () => {
$httpBackend.expectDELETE(/^registrants\/.+$/).respond(204, '');
- scope.deleteRegistrant(scope.registrants[0]);
+ const registrant = scope.registrants[0];
+ scope.deleteRegistrant(registrant);
fakeModal.close();
$httpBackend.flush();
expect(scope.registrations.length).toBe(1);
expect(scope.registrants.length).toBe(1);
- expect(scope.registrations[0].registrants.map((r) => r.id)).toEqual([
- 'c0855056-efc8-4ea7-81aa-4b0902376db1',
- ]);
+ expect(scope.registrations[0].registrants.map((r) => r.id)).not.toContain(
+ registrant.id,
+ );
expect(scope.registrations[0].groupRegistrants.length).toBe(0);
});
diff --git a/test/spec/controllers/reviewRegistration.spec.js b/test/spec/controllers/reviewRegistration.spec.js
index 11cca8c01..37474ff7f 100644
--- a/test/spec/controllers/reviewRegistration.spec.js
+++ b/test/spec/controllers/reviewRegistration.spec.js
@@ -55,23 +55,25 @@ describe('Controller: ReviewRegistrationCtrl', function () {
describe('currentPayment', () => {
it('should have balance set to the remaining balance', () => {
- expect(scope.currentPayment.amount).toBe(49);
+ expect(scope.currentPayment.amount).toBe(
+ testData.registration.remainingBalance,
+ );
});
});
describe('findAnswer', () => {
- it('should return an answer', function () {
- expect(
- scope.findAnswer('9b83eebd-b064-4edf-92d0-7982a330272a').value,
- ).toBe('M');
+ it('finds an answer by its block id', function () {
+ const answer = testData.registration.registrants[0].answers[0];
+
+ expect(scope.findAnswer(answer.blockId)).toBe(answer);
});
});
describe('getBlock', () => {
it('finds a block by its id', () => {
- expect(scope.getBlock('e088fefc-eb9c-4904-b849-017facc9e063').title).toBe(
- 'Email',
- );
+ const block = testData.conference.registrationPages[0].blocks[0];
+
+ expect(scope.getBlock(block.id)).toBe(block);
});
});
@@ -130,6 +132,9 @@ describe('Controller: ReviewRegistrationCtrl', function () {
});
describe('isBlockInvalid', () => {
+ const registrantId = testData.registrants[0].id;
+ const blockId = 'block-1';
+
it('returns false when there are no errors', () => {
initController({
validateRegistrant: {
@@ -137,27 +142,17 @@ describe('Controller: ReviewRegistrationCtrl', function () {
},
});
- expect(
- scope.isBlockInvalid(
- '6bd0f946-b010-4ef5-83f0-51c17449baf3',
- 'e088fefc-eb9c-4904-b849-017facc9e063',
- ),
- ).toBe(false);
+ expect(scope.isBlockInvalid(registrantId, blockId)).toBe(false);
});
it('returns true when there are errors', () => {
initController({
validateRegistrant: {
- validate: () => ['e088fefc-eb9c-4904-b849-017facc9e063'],
+ validate: () => [blockId],
},
});
- expect(
- scope.isBlockInvalid(
- '6bd0f946-b010-4ef5-83f0-51c17449baf3',
- 'e088fefc-eb9c-4904-b849-017facc9e063',
- ),
- ).toBe(true);
+ expect(scope.isBlockInvalid(registrantId, blockId)).toBe(true);
});
});
@@ -175,7 +170,7 @@ describe('Controller: ReviewRegistrationCtrl', function () {
it('returns false when there are errors', () => {
initController({
validateRegistrant: {
- validate: () => ['e088fefc-eb9c-4904-b849-017facc9e063'],
+ validate: () => ['block-1'],
},
});