Skip to content

Commit

Permalink
update how we pass facilityIds to api to ensure multiple can be reque…
Browse files Browse the repository at this point in the history
…sted
  • Loading branch information
coope93 committed Sep 24, 2024
1 parent e6efe50 commit 616d30b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/applications/caregivers/actions/fetchFacilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const formatQueryParams = ({
const formatFacilityIdParams = () => {
let facilityIdParams = '';
if (facilityIds.length > 0) {
facilityIdParams = facilityIds.map(id => `facilityIds[]=${id}`).join('&');
facilityIdParams = `facilityIds=${facilityIds.join(',')}`;
}

return facilityIdParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe('CG fetchFacilities action', () => {

const expectedUrl = `${
environment.API_URL
}/v0/caregivers_assistance_claims/facilities?type=health&lat=${lat}&long=${long}&radius=${radius}&page=${page}&per_page=${perPage}&facilityIds[]=${
}/v0/caregivers_assistance_claims/facilities?type=health&lat=${lat}&long=${long}&radius=${radius}&page=${page}&per_page=${perPage}&facilityIds=${
facilityIds[0]
}&facilityIds[]=${facilityIds[1]}`;
},${facilityIds[1]}`;
sinon.assert.calledWith(apiRequestStub, expectedUrl);
});

Expand All @@ -48,6 +48,15 @@ describe('CG fetchFacilities action', () => {
sinon.assert.calledWith(apiRequestStub, expectedUrl);
});

it('formats facility ids correctly when only one facility id', async () => {
await fetchFacilities({ facilityIds: ['1'] });

const expectedUrl = `${
environment.API_URL
}/v0/caregivers_assistance_claims/facilities?type=health&facilityIds=1`;
sinon.assert.calledWith(apiRequestStub, expectedUrl);
});

it('formats facility addresses', async () => {
apiRequestStub.resolves(mockFacilitiesResponse);
const response = await fetchFacilities({ long, lat, perPage, radius });
Expand Down

0 comments on commit 616d30b

Please sign in to comment.