Skip to content

Commit

Permalink
fix alias comparator (#61764)
Browse files Browse the repository at this point in the history
* fix alias comparator

* added test
  • Loading branch information
Liza Katz authored Mar 30, 2020
1 parent 5605b46 commit 67bfaf8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ describe('filter manager utilities', () => {
expect(compareFilters([f1], [f2], COMPARE_ALL_OPTIONS)).toBeTruthy();
});

test('should compare alias with alias true', () => {
const f1 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
...buildQueryFilter({ _type: { match: { query: 'apache', type: 'phrase' } } }, 'index', ''),
};
const f2 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
...buildQueryFilter({ _type: { match: { query: 'apache', type: 'phrase' } } }, 'index', ''),
};

f2.meta.alias = 'wassup';
f2.meta.alias = 'dog';

expect(compareFilters([f1], [f2], { alias: true })).toBeFalsy();
});

test('should compare alias with COMPARE_ALL_OPTIONS', () => {
const f1 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const mapFilter = (

if (comparators.negate) cleaned.negate = filter.meta && Boolean(filter.meta.negate);
if (comparators.disabled) cleaned.disabled = filter.meta && Boolean(filter.meta.disabled);
if (comparators.disabled) cleaned.alias = filter.meta?.alias;
if (comparators.alias) cleaned.alias = filter.meta?.alias;

return cleaned;
};
Expand Down

0 comments on commit 67bfaf8

Please sign in to comment.