From e5f52401b2a839881fedef5a446f0ed21d2d34c2 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 11 Feb 2020 20:16:56 +0100 Subject: webui: typecheck remaining bug list components --- webui/src/__tests__/query.js | 62 -------------------------------------------- webui/src/__tests__/query.ts | 62 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 webui/src/__tests__/query.js create mode 100644 webui/src/__tests__/query.ts (limited to 'webui/src/__tests__') diff --git a/webui/src/__tests__/query.js b/webui/src/__tests__/query.js deleted file mode 100644 index 5f4b58eb..00000000 --- a/webui/src/__tests__/query.js +++ /dev/null @@ -1,62 +0,0 @@ -import { parse, stringify, quote } from '../list/Filter'; - -it('parses a simple query', () => { - expect(parse('foo:bar')).toEqual({ - foo: ['bar'], - }); -}); - -it('parses a query with multiple filters', () => { - 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 "nested" quotes\'')).toEqual({ - foo: ['bar "nested" quotes'], - }); - - expect(parse("foo:'escaped\\' quotes'")).toEqual({ - foo: ["escaped' quotes"], - }); -}); - -it('parses a query with repetitions', () => { - 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({ - foo: ['bar', 'baz'], - 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'"`); -}); - -it('stringifies params', () => { - expect(stringify({ foo: ['bar'] })).toEqual('foo:bar'); - expect(stringify({ foo: ['bar baz'] })).toEqual('foo:"bar baz"'); - expect(stringify({ foo: ['bar', 'baz'] })).toEqual('foo:bar foo:baz'); - expect(stringify({ foo: ['bar'], baz: ['foobar'] })).toEqual( - 'foo:bar baz:foobar' - ); -}); diff --git a/webui/src/__tests__/query.ts b/webui/src/__tests__/query.ts new file mode 100644 index 00000000..5f4b58eb --- /dev/null +++ b/webui/src/__tests__/query.ts @@ -0,0 +1,62 @@ +import { parse, stringify, quote } from '../list/Filter'; + +it('parses a simple query', () => { + expect(parse('foo:bar')).toEqual({ + foo: ['bar'], + }); +}); + +it('parses a query with multiple filters', () => { + 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 "nested" quotes\'')).toEqual({ + foo: ['bar "nested" quotes'], + }); + + expect(parse("foo:'escaped\\' quotes'")).toEqual({ + foo: ["escaped' quotes"], + }); +}); + +it('parses a query with repetitions', () => { + 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({ + foo: ['bar', 'baz'], + 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'"`); +}); + +it('stringifies params', () => { + expect(stringify({ foo: ['bar'] })).toEqual('foo:bar'); + expect(stringify({ foo: ['bar baz'] })).toEqual('foo:"bar baz"'); + expect(stringify({ foo: ['bar', 'baz'] })).toEqual('foo:bar foo:baz'); + expect(stringify({ foo: ['bar'], baz: ['foobar'] })).toEqual( + 'foo:bar baz:foobar' + ); +}); -- cgit