Skip to content

Commit

Permalink
Merge branch 'main' into fix/1500-seeing-service-capacity-when-it-is-…
Browse files Browse the repository at this point in the history
…not-applicable
  • Loading branch information
ssrome committed Sep 13, 2024
2 parents e2df757 + 2727b37 commit d39243b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ const toCSV = (establishmentId, entity, MAX_QUALIFICATIONS, downloadType) => {
); // in UK date format dd/mm/yyyy (Worker stores as YYYY-MM-DD)

// "STARTINSECT"
columns.push(entity.SocialCareStartDateValue === 'Yes' ? entity.SocialCareStartDateYear : '');
const socialCareStartDateMappings = {
Yes: entity.SocialCareStartDateYear,
No: '999',
};

columns.push(socialCareStartDateMappings[entity.SocialCareStartDateValue] || '');

// "APPRENTICE"
let apprenticeship = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,34 @@ describe('workerCSV', () => {
expect(csvAsArray[getWorkerColumnIndex('STARTDATE')]).to.equal('');
});

it('should return the correct code for social care start date', async () => {
worker.SocialCareStartDateValue = 'Yes';
worker.SocialCareStartDateYear = '1998';
describe('Social care start date', () => {
it('should return the correct code for social care start date', async () => {
worker.SocialCareStartDateValue = 'Yes';
worker.SocialCareStartDateYear = '1998';

const csv = toCSV(establishment.LocalIdentifierValue, worker, 3);
const csvAsArray = csv.split(',');
const csv = toCSV(establishment.LocalIdentifierValue, worker, 3);
const csvAsArray = csv.split(',');

expect(csvAsArray[getWorkerColumnIndex('STARTINSECT')]).to.equal(worker.YearArrivedYear);
});
it('should not return year if the social care start date is no', async () => {
worker.SocialCareStartDateValue = 'No';
expect(csvAsArray[getWorkerColumnIndex('STARTINSECT')]).to.equal(worker.YearArrivedYear);
});

const csv = toCSV(establishment.LocalIdentifierValue, worker, 3);
const csvAsArray = csv.split(',');
it('should return 999 if the social care start date value is No', async () => {
worker.SocialCareStartDateValue = 'No';

expect(csvAsArray[getWorkerColumnIndex('STARTINSECT')]).to.equal('');
const csv = toCSV(establishment.LocalIdentifierValue, worker, 3);
const csvAsArray = csv.split(',');

expect(csvAsArray[getWorkerColumnIndex('STARTINSECT')]).to.equal('999');
});

it('should return empty string if the social care start date value is null (question not answered)', async () => {
worker.SocialCareStartDateValue = null;

const csv = toCSV(establishment.LocalIdentifierValue, worker, 3);
const csvAsArray = csv.split(',');

expect(csvAsArray[getWorkerColumnIndex('STARTINSECT')]).to.equal('');
});
});

yesNoDontKnow.forEach((value) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { fireEvent, render } from '@testing-library/angular';
import { BehaviorSubject } from 'rxjs';
import { getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TrainingService } from '@core/services/training.service';
import { MockTrainingService, MockTrainingServiceWithPreselectedStaff } from '@core/test-utils/MockTrainingService';
import { getTestBed } from '@angular/core/testing';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Establishment } from '@core/model/establishment.model';
import { BackLinkService } from '@core/services/backLink.service';
import { ErrorSummaryService } from '@core/services/error-summary.service';
import { GroupedRadioButtonAccordionComponent } from '@shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component';
import { RadioButtonAccordionComponent } from '@shared/components/accordions/radio-button-accordion/radio-button-accordion.component';
import { SharedModule } from '@shared/shared.module';
import { RouterTestingModule } from '@angular/router/testing';
import { TrainingService } from '@core/services/training.service';
import { WindowRef } from '@core/services/window.ref';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { WorkerService } from '@core/services/worker.service';
import { workerBuilder } from '@core/test-utils/MockWorkerService';
import { establishmentBuilder } from '@core/test-utils/MockEstablishmentService';
import { Establishment } from '@core/model/establishment.model';
import { SelectTrainingCategoryComponent } from './select-training-category.component';
import { trainingCategories } from '@core/test-utils/MockTrainingCategoriesService';
import { MockTrainingService, MockTrainingServiceWithPreselectedStaff } from '@core/test-utils/MockTrainingService';
import { workerBuilder } from '@core/test-utils/MockWorkerService';
import { GroupedRadioButtonAccordionComponent } from '@shared/components/accordions/radio-button-accordion/grouped-radio-button-accordion/grouped-radio-button-accordion.component';
import { RadioButtonAccordionComponent } from '@shared/components/accordions/radio-button-accordion/radio-button-accordion.component';
import { SharedModule } from '@shared/shared.module';
import { fireEvent, render } from '@testing-library/angular';
import { BehaviorSubject } from 'rxjs';
import sinon from 'sinon';

import { SelectTrainingCategoryComponent } from './select-training-category.component';

describe('SelectTrainingCategoryComponent', () => {
async function setup(prefill = false, qsParamGetMock = sinon.fake()) {
const establishment = establishmentBuilder() as Establishment;
Expand Down Expand Up @@ -195,4 +196,14 @@ describe('SelectTrainingCategoryComponent', () => {

expect(component.form.value).toEqual({ category: 1 });
});

it('should display example messages for each training group', async () => {
const { component, getByText } = await setup();

expect(getByText("Training like 'duty of care', 'safeguarding adults'")).toBeTruthy();
expect(getByText("Training like 'fire safety', 'first aid'")).toBeTruthy();
expect(getByText("Training like 'online safety and security', 'working with digital technology'")).toBeTruthy();
expect(getByText("Training like 'dementia care', 'Oliver McGowan Mandatory Training'")).toBeTruthy();
expect(getByText("Training like 'communication', 'leadership and management'")).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SelectTrainingCategoryDirective implements OnInit, AfterViewInit {
'Health and safety in the workplace': "'fire safety', 'first aid'",
'IT, digital and data in the workplace': "'online safety and security', 'working with digital technology'",
'Specific conditions and disabilities': "'dementia care', 'Oliver McGowan Mandatory Training'",
'Staff development': "'communication', 'equality and diversity'",
'Staff development': "'communication', 'leadership and management' ",
};
submitButtonText: string = 'Continue';

Expand Down

0 comments on commit d39243b

Please sign in to comment.