Skip to content

Commit a6b54c6

Browse files
committed
Addressed error messages in tests; removed old code and replaced with comments
1 parent 4974067 commit a6b54c6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/helpers/valueSetUtils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function loadVs(absoluteFilepath, typeOfVS) {
3131
throw Error('No defined valueset loader for `turtle` type valuesets');
3232

3333
default:
34-
throw Error(`${typeOfVS}' is not a recognized valueset type`);
34+
throw Error(`'${typeOfVS}' is not a recognized valueset type`);
3535
}
3636
}
3737

@@ -49,14 +49,16 @@ const checkCodeInVs = (code, valueSetFilePath, typeOfVS = vsTypes.json) => {
4949
// If valueSet has expansion, we only need to check these codes
5050
inVSExpansion = valueSet.expansion.contains.some((containsItem) => {
5151
if (!code || !containsItem) return false;
52-
// return code.system === containsItem.system && code === containsItem.code;
52+
// NOTE: This is a technically incorrect interpretation of ValueSets;
53+
// this matching ought to check both code and system
5354
return code === containsItem.code;
5455
});
5556
} else {
5657
// Checks if code is in any of the valueSet.compose.include arrays
5758
inVSCompose = valueSet.compose.include.some((includeItem) => {
5859
if (!code || !includeItem || !includeItem.concept) return false;
59-
// return c.system === includeItem.system && includeItem.concept.map((concept) => concept.code).includes(code);
60+
// NOTE: This is a technically incorrect interpretation of ValueSets;
61+
// this matching ought to check both code and system
6062
return includeItem.concept.map((concept) => concept.code).includes(code);
6163
});
6264
}

test/helpers/valueSetUtils.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('valueSetUtils', () => {
2020
expect(() => loadJsonVs()).toThrow();
2121
});
2222
test('should throw when file does not exist', () => {
23-
expect(() => loadJsonVs('./path/does/not/exist')).toThrow();
23+
expect(() => loadJsonVs('./path/does/not/exist')).toThrow("ENOENT: no such file or directory, open './path/does/not/exist'");
2424
});
2525
test('should load from the supplied filepath', () => {
2626
const valueSetFilePath = path.resolve(__dirname, 'fixtures', 'valueset-without-expansion.json');
@@ -30,13 +30,13 @@ describe('valueSetUtils', () => {
3030

3131
describe('loadVs', () => {
3232
test('should throw an error when xml type is provided', () => {
33-
expect(() => loadVs(undefined, vsTypes.xml)).toThrow();
33+
expect(() => loadVs(undefined, vsTypes.xml)).toThrow('No defined valueset loader for `xml` type valuesets');
3434
});
3535
test('should throw an error when turtle is provided', () => {
36-
expect(() => loadVs(undefined, vsTypes.turtle)).toThrow();
36+
expect(() => loadVs(undefined, vsTypes.turtle)).toThrow('No defined valueset loader for `turtle` type valuesets');
3737
});
3838
test('should throw an error when an unrecoginized type is provided', () => {
39-
expect(() => loadVs(undefined, vsTypes.newType)).toThrow();
39+
expect(() => loadVs(undefined, vsTypes.newType)).toThrow("'undefined' is not a recognized valueset type");
4040
});
4141
test('Should load a vs properly for json', () => {
4242
const valueSetFilePath = path.resolve(__dirname, 'fixtures', 'valueset-without-expansion.json');

0 commit comments

Comments
 (0)