aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/__tests__/query.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webui/src/__tests__/query.ts')
-rw-r--r--webui/src/__tests__/query.ts61
1 files changed, 44 insertions, 17 deletions
diff --git a/webui/src/__tests__/query.ts b/webui/src/__tests__/query.ts
index 2f04817c..f8ff6360 100644
--- a/webui/src/__tests__/query.ts
+++ b/webui/src/__tests__/query.ts
@@ -7,49 +7,76 @@ it('parses a simple query', () => {
});
it('parses a query with multiple filters', () => {
- expect(parse('foo:bar baz:foo-bar')).toEqual({
+ expect(parse(`foo:bar baz:foo-bar`)).toEqual({
foo: ['bar'],
baz: ['foo-bar'],
});
});
it('parses a quoted query', () => {
- expect(parse('foo:"bar"')).toEqual({
- foo: ['bar'],
+ expect(parse(`foo:"bar"`)).toEqual({
+ foo: [`"bar"`],
});
- expect(parse("foo:'bar'")).toEqual({
- foo: ['bar'],
+ expect(parse(`foo:'bar'`)).toEqual({
+ foo: [`'bar'`],
+ });
+
+ expect(parse(`label:abc freetext`)).toEqual({
+ label: [`abc`],
+ freetext: [''],
+ });
+
+ expect(parse(`label:abc with "quotes" in freetext`)).toEqual({
+ label: [`abc`],
+ with: [''],
+ quotes: [''],
+ in: [''],
+ freetext: [''],
+ });
+
+ expect(parse(`label:'multi word label'`)).toEqual({
+ label: [`'multi word label'`],
+ });
+
+ expect(parse(`label:"multi word label"`)).toEqual({
+ label: [`"multi word label"`],
+ });
+
+ expect(parse(`label:'multi word label with "nested" quotes'`)).toEqual({
+ label: [`'multi word label with "nested" quotes'`],
});
- expect(parse('foo:\'bar "nested" quotes\'')).toEqual({
- foo: ['bar "nested" quotes'],
+ expect(parse(`label:"multi word label with 'nested' quotes"`)).toEqual({
+ label: [`"multi word label with 'nested' quotes"`],
});
- expect(parse("foo:'escaped\\' quotes'")).toEqual({
- foo: ["escaped' quotes"],
+ expect(parse(`foo:'escaped\\' quotes'`)).toEqual({
+ foo: [`'escaped\\' quotes'`],
});
});
it('parses a query with repetitions', () => {
- expect(parse('foo:bar foo:baz')).toEqual({
+ expect(parse(`foo:bar foo:baz`)).toEqual({
foo: ['bar', 'baz'],
});
});
it('parses a complex query', () => {
- expect(parse('foo:bar foo:baz baz:"foobar" idont:\'know\'')).toEqual({
+ expect(parse(`foo:bar foo:baz baz:"foobar" idont:'know'`)).toEqual({
foo: ['bar', 'baz'],
- baz: ['foobar'],
- idont: ['know'],
+ baz: [`"foobar"`],
+ idont: [`'know'`],
});
});
it('quotes values', () => {
- expect(quote('foo')).toEqual('foo');
- expect(quote('foo bar')).toEqual('"foo bar"');
- expect(quote('foo "bar"')).toEqual(`'foo "bar"'`);
- expect(quote(`foo "bar" 'baz'`)).toEqual(`"foo \\"bar\\" 'baz'"`);
+ expect(quote(`foo`)).toEqual(`foo`);
+ expect(quote(`foo bar`)).toEqual(`"foo bar"`);
+ expect(quote(`foo "bar"`)).toEqual(`"foo "bar""`);
+ expect(quote(`foo 'bar'`)).toEqual(`"foo "bar""`);
+ expect(quote(`'foo'`)).toEqual(`"foo"`);
+ expect(quote(`foo "bar" 'baz'`)).toEqual(`"foo "bar" "baz""`);
});
it('stringifies params', () => {