From 817732948d3b7cf0e7a4c2987cd0f7dd5729288b Mon Sep 17 00:00:00 2001 From: Sascha Date: Mon, 3 May 2021 15:15:21 +0200 Subject: Add test cases Key:Value parsing test for quoated colon. E.g. label:"foo:bar" Key:Value:Value parsing test. E.g. metadata:key:"https://www.example.com/" --- webui/src/__tests__/query.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'webui/src/__tests__') diff --git a/webui/src/__tests__/query.ts b/webui/src/__tests__/query.ts index f8ff6360..7abcecd2 100644 --- a/webui/src/__tests__/query.ts +++ b/webui/src/__tests__/query.ts @@ -11,16 +11,6 @@ it('parses a query with multiple filters', () => { 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(`label:abc freetext`)).toEqual({ label: [`abc`], @@ -35,6 +25,17 @@ it('parses a quoted query', () => { freetext: [''], }); +}); + +it('parses a quoted query', () => { + expect(parse(`foo:"bar"`)).toEqual({ + foo: [`"bar"`], + }); + + expect(parse(`foo:'bar'`)).toEqual({ + foo: [`'bar'`], + }); + expect(parse(`label:'multi word label'`)).toEqual({ label: [`'multi word label'`], }); @@ -51,6 +52,10 @@ it('parses a quoted query', () => { label: [`"multi word label with 'nested' quotes"`], }); + expect(parse(`label:"with:quoated:colon"`)).toEqual({ + label: [`"with:quoated:colon"`], + }); + expect(parse(`foo:'escaped\\' quotes'`)).toEqual({ foo: [`'escaped\\' quotes'`], }); @@ -70,6 +75,12 @@ it('parses a complex query', () => { }); }); +it('parses a key:value:value query', () => { + expect(parse(`meta:github:"https://github.com/MichaelMure/git-bug"`)).toEqual({ + meta: [`github:"https://github.com/MichaelMure/git-bug"`], + }); +}); + it('quotes values', () => { expect(quote(`foo`)).toEqual(`foo`); expect(quote(`foo bar`)).toEqual(`"foo bar"`); -- cgit