Skip to content

Commit

Permalink
adds test case for list.id operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dasansol92 committed Jul 28, 2021
1 parent 45a66fd commit 9dba145
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@
import { parseQueryFilterToKQL } from './utils';

describe('utils', () => {
const searchableFields = [`name`, `description`, `entries.value`, `entries.entries.value`];
const searchableFields = [
'name',
'description',
'entries.value',
'entries.entries.value',
'entries.list.id',
];
describe('parseQueryFilterToKQL', () => {
it('should parse simple query without term', () => {
expect(parseQueryFilterToKQL('', searchableFields)).toBe('');
});
it('should parse simple query with term', () => {
expect(parseQueryFilterToKQL('simpleQuery', searchableFields)).toBe(
'(exception-list-agnostic.attributes.name:(*simpleQuery*) OR exception-list-agnostic.attributes.description:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.entries.value:(*simpleQuery*))'
'(exception-list-agnostic.attributes.name:(*simpleQuery*) OR exception-list-agnostic.attributes.description:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.entries.value:(*simpleQuery*) OR exception-list-agnostic.attributes.entries.list.id:(*simpleQuery*))'
);
});
it('should parse complex query with term', () => {
expect(parseQueryFilterToKQL('complex query', searchableFields)).toBe(
'(exception-list-agnostic.attributes.name:(*complex*query*) OR exception-list-agnostic.attributes.description:(*complex*query*) OR exception-list-agnostic.attributes.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.entries.value:(*complex*query*))'
'(exception-list-agnostic.attributes.name:(*complex*query*) OR exception-list-agnostic.attributes.description:(*complex*query*) OR exception-list-agnostic.attributes.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.entries.value:(*complex*query*) OR exception-list-agnostic.attributes.entries.list.id:(*complex*query*))'
);
});
it('should parse complex query with colon and backslash chars term', () => {
expect(parseQueryFilterToKQL('C:\\tmpes', searchableFields)).toBe(
'(exception-list-agnostic.attributes.name:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.description:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.entries.value:(*C\\:\\\\tmpes*))'
'(exception-list-agnostic.attributes.name:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.description:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.entries.value:(*C\\:\\\\tmpes*) OR exception-list-agnostic.attributes.entries.list.id:(*C\\:\\\\tmpes*))'
);
});
it('should parse complex query with special chars term', () => {
Expand All @@ -35,7 +41,7 @@ describe('utils', () => {
searchableFields
)
).toBe(
"(exception-list-agnostic.attributes.name:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.description:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*))"
"(exception-list-agnostic.attributes.name:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.description:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.entries.value:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*) OR exception-list-agnostic.attributes.entries.list.id:(*this'is%&query\\{\\}[]!¿?with.,-+`´special\\<\\>ºª@#|·chars*))"
);
});
});
Expand Down

0 comments on commit 9dba145

Please sign in to comment.