Skip to content

Commit

Permalink
Merge pull request #6309 from NMDSdevopsServiceAdm/remove-tdf-option-…
Browse files Browse the repository at this point in the history
…from-registration-survey

Remove TDF checkbox from Why did you create an account page
  • Loading branch information
duncanc19 authored Aug 1, 2024
2 parents a10f762 + 681a3f7 commit d88edb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { getTestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { RegistrationSurveyService } from '@core/services/registration-survey.service';
import { SharedModule } from '@shared/shared.module';
Expand All @@ -18,11 +19,14 @@ describe('WhyCreateAccountComponent', () => {
const component = fixture.componentInstance;

const injector = getTestBed();
const registrationSurveyService = injector.inject(RegistrationSurveyService);

const registrationSurveyService = injector.inject(RegistrationSurveyService);
const registrationSurveyServiceSpy = spyOn(registrationSurveyService, 'updatewhyCreateAccountState');

return { fixture, component, getByText, registrationSurveyServiceSpy };
const router = injector.inject(Router);
const routerSpy = spyOn(router, 'navigate');

return { fixture, component, getByText, registrationSurveyServiceSpy, routerSpy };
}

it('should create', async () => {
Expand Down Expand Up @@ -52,15 +56,15 @@ describe('WhyCreateAccountComponent', () => {
const { getByText, registrationSurveyServiceSpy } = await setup();

const benefitsCheckboxText = 'To get access to the Benefits Bundle';
const fundCheckboxText = 'To get access to the Adult Social Care Training and Development Fund';
const manageStaffRecordsText = 'To record and manage staff records';

fireEvent.click(getByText(benefitsCheckboxText));
fireEvent.click(getByText(fundCheckboxText));
fireEvent.click(getByText(manageStaffRecordsText));

const nextQuestionButton = getByText('Next question');
fireEvent.click(nextQuestionButton);

expect(registrationSurveyServiceSpy).toHaveBeenCalledWith([benefitsCheckboxText, fundCheckboxText]);
expect(registrationSurveyServiceSpy).toHaveBeenCalledWith([benefitsCheckboxText, manageStaffRecordsText]);
});

it('should call updatewhyCreateAccountState in registration service with empty array when no checkboxes selected', async () => {
Expand All @@ -73,9 +77,11 @@ describe('WhyCreateAccountComponent', () => {
});

it('should navigate to the next question', async () => {
const component = await setup();
const { getByText, routerSpy } = await setup();

const nextQuestionButton = getByText('Next question');
fireEvent.click(nextQuestionButton);

const nextPage = component.fixture.componentInstance.nextPage;
expect(nextPage.url).toEqual(['/registration-survey', 'how-did-you-hear-about']);
expect(routerSpy).toHaveBeenCalledWith(['/registration-survey', 'how-did-you-hear-about']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class WhyCreateAccountComponent implements OnInit {
'To record and manage staff records',
'To benchmark our workplace against others',
'To help us understand our workforce better',
'To get access to the Adult Social Care Training and Development Fund',
'Other',
];
public form: UntypedFormGroup;
Expand Down

0 comments on commit d88edb8

Please sign in to comment.