Commit 0af419d3 authored by samdbeckham's avatar samdbeckham

Fixes a bug with watched getters in the filters

parent 1d1e95c8
......@@ -5,8 +5,12 @@ export default {
const { filterId, optionId } = payload;
const activeFilter = state.filters.find(filter => filter.id === filterId);
if (activeFilter) {
activeFilter.options.find(option => option.selected).selected = false;
activeFilter.options.find(option => option.id === optionId).selected = true;
activeFilter.options = [
...activeFilter.options.map(option => ({
...option,
selected: option.id === optionId,
})),
];
}
},
};
......@@ -7,12 +7,11 @@ describe('filters module mutations', () => {
let state;
let typeFilter;
let sastOption;
let allOption;
beforeEach(() => {
state = createState();
[typeFilter] = state.filters;
[allOption, sastOption] = typeFilter.options;
[, sastOption] = typeFilter.options;
mutations[types.SET_FILTER](state, {
filterId: typeFilter.id,
......@@ -21,11 +20,11 @@ describe('filters module mutations', () => {
});
it('should make SAST the selected option', () => {
expect(sastOption.selected).toEqual(true);
expect(state.filters[0].options[1].selected).toEqual(true);
});
it('should remove ALL as the selected option', () => {
expect(allOption.selected).toEqual(false);
expect(state.filters[0].options[0].selected).toEqual(false);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment