Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] read value description from user dictionary correctly #623

Merged
merged 4 commits into from
Nov 13, 2023
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
4 changes: 2 additions & 2 deletions cypress/fixtures/examples/good/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"sex": {
"Description": "sex of the participant as reported by the participant",
"Levels": {
"M": "male",
"F": "female"
"1": "male",
"2": "female"
}
},
"group": {
Expand Down
18 changes: 7 additions & 11 deletions cypress/unit/store-getter-getValueDescription.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ const state = {
dataDictionary: {
annotated: {
"goodColumn": {
"levels": {
"value1": {
"description": "my description"
},
"value2": {
"description": "my other description"
"Levels": {
"value1": "my description",
"value2": "my other description"
}
}
},
"levelsButNothingElse": {
"levels": {
"Levels": {
}
},
"badColumn": {
Expand All @@ -33,12 +29,12 @@ describe("getValueDescription", () => {
expect(result).to.be.equal("my description");
});

it("Returns an empty string if the value does not have a description", () => {
it("Returns 'no description available' if the value does not have a description", () => {

const resultNoValue = getters.getValueDescription(state)("levelsButNothingElse", "notExistValue");
expect(resultNoValue).to.be.empty;
expect(resultNoValue).to.be.equal("no description available");

const resultNoLevels = getters.getValueDescription(state)("badColumn", "notExistValue");
expect(resultNoLevels).to.be.empty;
expect(resultNoLevels).to.be.equal("no description available");
});
});
4 changes: 2 additions & 2 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ export const getters = {
getValueDescription: (p_state) => (p_columnName, p_value) => {
// Returns the description of a value in a column, if that description exists
// Otherwise it returns an empty string
const description = p_state.dataDictionary.annotated[p_columnName].levels?.[p_value]?.description;
const description = p_state.dataDictionary.annotated[p_columnName].Levels?.[p_value];
if ( typeof description === "undefined" ) {
return "";
return "no description available";
surchs marked this conversation as resolved.
Show resolved Hide resolved
}
return description;
},
Expand Down