Skip to content

Commit

Permalink
PAF-74 Allow attachment URLs into SQS payload (#106)
Browse files Browse the repository at this point in the history
* PAF-74 Allow attachment URLs into SQS payload

* Altered conditionals stopping 'image' array from being added to payload
* Fixed a typo
* Removed an unnecessary log

* PAF-74 fix typo causing unit test to fail
  • Loading branch information
jamiecarterHO authored Jan 19, 2024
1 parent 814cc7a commit a79687d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions lib/add-allegation-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const valuesMap = require('./ims-hof-values-map.json');
const eform = {
EformFields: [],
AdditionalPeople: [],
Attachements: []
Attachments: []
};

const addFieldToEform = (fieldName, fieldValue) => {
if (fieldName === 'images') {
eform.Attachements.push({url: fieldValue});
eform.Attachments = fieldValue;
} else if (fieldName === 'txpermoreallholder') {
eform.AdditionalPeople.push({FieldName: fieldName, FieldValue: fieldValue});
} else {
Expand All @@ -31,7 +31,6 @@ const addField = (name, value) => {
}
}
if (name === 'images') {
console.log('Value :: ', value);
addFieldToEform(name, value);
}
};
Expand All @@ -43,7 +42,7 @@ const addGroup = value => {
const addAllegationData = data => {
Object.entries(data).forEach(entry => {
const [key, value] = entry;
if (value !== '' && key !== 'images') {
if (value !== '') {
if (key.includes('group')) {
const groups = Array.isArray(value) ? value : value.split(',');
groups.map(addGroup);
Expand Down
4 changes: 2 additions & 2 deletions test/_unit/behaviours/add-allegation-data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ describe("apps/lib 'add-allegation-data' behaviour should ", () => {
addAllegationDataWithAdditionalPerAndFileRes = addAllegationData(dataWithAdditionalPersonAndFile);
});

it('addAlligationData response have EformFields, AdditionalPeople, Attachements', () => {
it('addAlligationData response have EformFields, AdditionalPeople, Attachments', () => {
JSON.parse(addAllegationDataWithAdditionalPerAndFileRes).should.have.property('EformFields');
JSON.parse(addAllegationDataWithAdditionalPerAndFileRes).should.have.property('AdditionalPeople');
JSON.parse(addAllegationDataWithAdditionalPerAndFileRes).should.have.property('Attachements');
JSON.parse(addAllegationDataWithAdditionalPerAndFileRes).should.have.property('Attachments');
});

it('addAlligationData contain rdpermoreinfomore set to true when Additional person is selected', () => {
Expand Down

0 comments on commit a79687d

Please sign in to comment.