Skip to content

Commit

Permalink
🐛 fix wrapping content causing failures
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis committed Dec 10, 2024
1 parent 59adf4b commit 79b1b5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mutations/calculate-building-id/calculate-building-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ async function calculateBuildingId(parent, input, context) {
const data = {
...input,
images: JSON.stringify(input.images),
building_material: input.building_material?.trim(),
building_project: input.building_project?.trim(),
location_address: input.location_address?.trim(),
location_district: input.location_district?.trim(),
location_parish: input.location_parish?.trim(),
cadastre_number: input.cadastre_number?.trim(),
};

const addr = normalizeAddress(data);
Expand Down
16 changes: 16 additions & 0 deletions src/mutations/calculate-building-id/calculate-building-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,20 @@ describe('calculateBuildingId', () => {

expect(output).toEqual(123);
});

test('trims the cadastre_number field before inserting', async () => {
await calculateBuildingId(
{},
{ ...mockInput, cadastre_number: '\n\t\t\t\t\t\t123\n\t\t\t\t\t\t' },
{
dataSources,
},
);

expect(dataSources.userClassifieds.create).toHaveBeenCalledWith(
expect.objectContaining({
cadastre_number: '123',
}),
);
});
});

0 comments on commit 79b1b5d

Please sign in to comment.