Commit 23a368a9 authored by Martin Wortschack's avatar Martin Wortschack

Set selectedLabels to empty array

- When no label_name filter is applied
the selectedLabels array needs
to be set to an empty array.
parent 686f9e53
......@@ -17,7 +17,7 @@ const transformFilters = filters => {
'not[milestone_title]': notMilestoneTitle,
} = filters;
let selectedLabels = labelNames?.map(label => ({ value: label, operator: '=' }));
let selectedLabels = labelNames?.map(label => ({ value: label, operator: '=' })) || [];
let selectedMilestone = null;
if (notLabelNames) {
......
......@@ -19,18 +19,32 @@ describe('CodeReviewAnalytics utils', () => {
});
describe('when "not[label_name]" filter is present', () => {
it('applies the "!=" operator to the selectedLabels array', () => {
const filters = {
milestone_title: 'my-milestone',
label_name: ['my-label'],
'not[label_name]': ['another label'],
};
expect(transformFilters(filters)).toEqual({
selectedMilestone: { value: 'my-milestone', operator: '=' },
selectedLabels: [
{ value: 'my-label', operator: '=' },
{ value: 'another label', operator: '!=' },
],
describe('and "label_name" filter is present', () => {
it('applies the "!=" operator to the selectedLabels array', () => {
const filters = {
milestone_title: 'my-milestone',
label_name: ['my-label'],
'not[label_name]': ['another label'],
};
expect(transformFilters(filters)).toEqual({
selectedMilestone: { value: 'my-milestone', operator: '=' },
selectedLabels: [
{ value: 'my-label', operator: '=' },
{ value: 'another label', operator: '!=' },
],
});
});
});
describe('and "label_name" filter is missing', () => {
it('applies the "!=" operator to the selectedLabels array', () => {
const filters = {
'not[label_name]': ['another label'],
};
expect(transformFilters(filters)).toEqual({
selectedLabels: [{ value: 'another label', operator: '!=' }],
selectedMilestone: null,
});
});
});
});
......
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