Skip to content

Commit

Permalink
Merge pull request #6357 from NMDSdevopsServiceAdm/fix/bulk-upload-do…
Browse files Browse the repository at this point in the history
…wnload-start-in-sector

Updated download of start in sector to set No to 999 and empty string when unanswered
  • Loading branch information
duncanc19 authored Sep 12, 2024
2 parents 19c1339 + a48d076 commit 0179c49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 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

0 comments on commit 0179c49

Please sign in to comment.