Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/modules/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export const createCase = (http) => (caseTypeId) => (eventId) => async (payload
*
* @param {httpClient} http Configured, ready-to-use HTTP client
* @param {string|number} caseId 16-digit unique case identifier
* @param {object} - request parameters for the get request
* @return {Promise} Promise resolved with the case for the given identifier.
*/
export const fetchCase = (http) => (caseId) => async () => {
export const fetchCase = (http) => (caseId, params) => async () => {
const url = `/cases/${caseId}`;
const res = await http.get(url);
const res = await http.get(url, params);
return res.data;
};

Expand Down
18 changes: 18 additions & 0 deletions src/modules/case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ describe('fetchCase', () => {
const actualData = await fetchCase(httpStub)(caseId)();
expect(actualData).toEqual(resData);
});

test('should fetch case by id with request parameters', async () => {
const caseId = '1234123412341238';
const resData = {
id: caseId,
data: {},
};
const httpStub = {
get: (url, params) => {
expect(url).toEqual(`/cases/${caseId}`);
expect(params).toEqual({field: 'field1'});
return Promise.resolve({data: resData});
},
};

const actualData = await fetchCase(httpStub)(caseId, {field: 'field1'})();
expect(actualData).toEqual(resData);
});
});

describe('fieldExtractor', () => {
Expand Down
Loading