Skip to content

Commit

Permalink
Refactor unit tests to follow updated store column getter
Browse files Browse the repository at this point in the history
Looks like we did remove the dupliacted getter after all?
  • Loading branch information
surchs committed Oct 17, 2023
1 parent 7bd666d commit ea0dbc8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions components/annot-columns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
data-cy="mappedColumns"
class="d-flex justify-content-between align-items-center"
:key="columnName"
v-for="columnName of getMappedColumns(activeCategory)">
v-for="columnName of getColumnsForCategory(activeCategory)">
{{ columnName }} {{ getColumnDescription(columnName) }}
<b-button
:data-cy="'remove_' + columnName"
Expand Down Expand Up @@ -57,7 +57,7 @@
computed: {
...mapGetters([
"getMappedColumns",
"getColumnsForCategory",
"getColumnDescription"
])
},
Expand Down
4 changes: 2 additions & 2 deletions components/annot-continuous-values.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<b-tabs content-class="mt-3">

<b-tab
v-for="(columnName, index) in getMappedColumns(activeCategory)"
v-for="(columnName, index) in getColumnsForCategory(activeCategory)"
:key="columnName"
:active="0 === index"
:title="columnName">
Expand Down Expand Up @@ -93,7 +93,7 @@
"getHarmonizedPreview",
"getHeuristic",
"getMappedColumns",
"getColumnsForCategory",
"getTransformOptions",
"getUniqueValues"
])
Expand Down
2 changes: 1 addition & 1 deletion cypress/component/annot-columns.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import annotColumns from "~/components/annot-columns.vue";
const store = {
commit: () => {},
getters: {
getMappedColumns: () => (activeCategory) => {
getColumnsForCategory: () => (activeCategory) => {
return [
"column1",
"column2",
Expand Down
6 changes: 3 additions & 3 deletions cypress/component/annot-continuous-values.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Continuous values component", () => {

return store.state.dataDictionary.annotated[p_column].transformationHeuristic;
},
getMappedColumns: () => (p_activeCategory) => {
getColumnsForCategory: () => (p_activeCategory) => {

return ["column1"];
},
Expand Down Expand Up @@ -153,7 +153,7 @@ describe("Continuous values component", () => {

// Setup
store.state.dataDictionary.annotated["column2"] = { transformationHeuristic: "" };
store.getters.getMappedColumns = () => (p_activeCategory) => {
store.getters.getColumnsForCategory = () => (p_activeCategory) => {

return ["column1", "column2"];
};
Expand Down Expand Up @@ -196,7 +196,7 @@ describe("Continuous values component", () => {

// Setup
store.state.dataDictionary.annotated["column2"] = { transformationHeuristic: "" };
store.getters.getMappedColumns = () => (p_activeCategory) => {
store.getters.getColumnsForCategory = () => (p_activeCategory) => {

return ["column1", "column2"];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ const store = {
}
};

describe("getMappedColumns", () => {
describe("getColumnsForCategory", () => {

it("Gets list of columns of a given category", () => {

// Assert
expect(getters.getMappedColumns(store.state)("category1")).to.deep.equal(["column1", "column3"]);
expect(getters.getColumnsForCategory(store.state)("category1")).to.deep.equal(["column1", "column3"]);
});

it("Gets empty list if a given category is not assigned to any columns", () => {

// Assert
expect(getters.getMappedColumns(store.state)("category4")).to.deep.equal([]);
expect(getters.getColumnsForCategory(store.state)("category4")).to.deep.equal([]);
});
});
});
6 changes: 3 additions & 3 deletions cypress/unit/store-mutation-alterColumnToToolMap.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ describe("alterColumnToToolMapping", () => {

it("Maps column to tool if it's not already mapped", () => {

mutations.alterColumnToToolMapping(store.state, "column2", "cogatlas:MOCA");
mutations.alterColumnToToolMapping(store.state, {columnName: "column2", toolIdentifier: "cogatlas:MOCA"});
expect(store.state.columnToToolMap.column2).to.equal("cogatlas:MOCA");
});

it("Maps column to new tool overwriting previous mapping", () => {

mutations.alterColumnToToolMapping(store.state, "column3", "cogatlas:MOCA");
mutations.alterColumnToToolMapping(store.state, {columnName: "column3", toolIdentifier: "cogatlas:MOCA"});
expect(store.state.columnToToolMap.column3).to.equal("cogatlas:MOCA");
});

it("Sets mapping to null if it's already mapped", () => {

mutations.alterColumnToToolMapping(store.state, "column1", "cogatlas:MOCA");
mutations.alterColumnToToolMapping(store.state, {columnName: "column1", toolIdentifier: "cogatlas:MOCA"});
expect(store.state.columnToToolMap.column1).to.equal(null);
});
});
4 changes: 2 additions & 2 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@ export const mutations = {
}
},

alterColumnToToolMapping(p_state, columnName, toolIdentifier) {
if ( p_state.columnToToolMap[columnName] == toolIdentifier ) {
alterColumnToToolMapping(p_state, {columnName, toolIdentifier}) {
if ( p_state.columnToToolMap[columnName] === toolIdentifier ) {
p_state.columnToToolMap[columnName] = null;
} else {
p_state.columnToToolMap[columnName] = toolIdentifier;
Expand Down

0 comments on commit ea0dbc8

Please sign in to comment.