Skip to content

Commit 9c8a8eb

Browse files
committed
updated tests and error message
1 parent a4691f8 commit 9c8a8eb

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/helpers/contextUtils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function getPatientFromContext(mrn, context) {
1818
* @return {Array} All the conditions entries found in context
1919
*/
2020
function getConditionEntriesFromContext(context) {
21-
logger.debug('Getting conditions from context');
21+
logger.debug('Getting condition entries from context');
2222
const conditionEntriesInContext = getBundleEntriesByResourceType(context, 'Condition', {}, false);
2323
if (conditionEntriesInContext.length === 0) {
2424
throw Error('Could not find any conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
2525
}
26-
logger.debug(`Condition resources found in context. Found ${conditionEntriesInContext.length} condition resources.`);
26+
logger.debug(`Condition entries found in context. Found ${conditionEntriesInContext.length} condition resources.`);
2727
return conditionEntriesInContext;
2828
}
2929

@@ -33,12 +33,12 @@ function getConditionEntriesFromContext(context) {
3333
* @return {Array} All the conditions resources found in context
3434
*/
3535
function getConditionsFromContext(context) {
36-
logger.debug('Getting conditions from context');
36+
logger.debug('Getting condition resources from context');
3737
const conditionsResourcesInContext = getBundleResourcesByType(context, 'Condition', {}, false);
3838
if (_.isEmpty(conditionsResourcesInContext)) {
39-
throw Error('Could not find conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
39+
throw Error('Could not find any conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
4040
}
41-
logger.debug('Condition resources found in context.');
41+
logger.debug(`Condition resources found in context. Found ${conditionsResourcesInContext.length} condition resources.`);
4242
return conditionsResourcesInContext;
4343
}
4444

test/helpers/contextUtils.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ describe('getConditionsFromContext', () => {
5050
},
5151
],
5252
};
53-
test('Should return Patient resource in context', () => {
54-
const conditions = getConditionsFromContext(MOCK_PATIENT_MRN, conditionContext);
53+
test('Should return Condition resource in context', () => {
54+
const conditions = getConditionsFromContext(conditionContext);
5555
expect(conditions).toContain(conditionResource);
5656
expect(conditions).toContain(conditionResource2);
5757
});
5858

5959
test('Should throw an error if there is no patient in context', () => {
60-
expect(() => getConditionsFromContext(MOCK_PATIENT_MRN, {}))
61-
.toThrow('Could not find conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
60+
expect(() => getConditionsFromContext({}))
61+
.toThrow('Could not find any conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
6262
});
6363
});
6464

65-
describe('getConditionFromContext', () => {
65+
describe('getConditionEntriesFromContext', () => {
6666
const conditionResource = {
6767
resourceType: 'Condition',
6868
id: 'mCODEConditionExample01',
@@ -82,8 +82,8 @@ describe('getConditionFromContext', () => {
8282
],
8383
};
8484

85-
test('Should return all Condition resources in context', () => {
86-
const conditions = getConditionEntriesFromContext(MOCK_PATIENT_MRN, conditionContext);
85+
test('Should return all Condition entries in context', () => {
86+
const conditions = getConditionEntriesFromContext(conditionContext);
8787
expect(conditions).toHaveLength(2);
8888
expect(conditions[0]).toEqual({
8989
fullUrl: 'context-url-1',
@@ -92,7 +92,7 @@ describe('getConditionFromContext', () => {
9292
});
9393

9494
test('Should throw an error if there are no conditions in context', () => {
95-
expect(() => getConditionEntriesFromContext(MOCK_PATIENT_MRN, {}))
95+
expect(() => getConditionEntriesFromContext({}))
9696
.toThrow('Could not find any conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
9797
});
9898
});

0 commit comments

Comments
 (0)