diff --git a/web-console/src/views/query-view/query-input/__snapshots__/query-input.spec.tsx.snap b/web-console/src/views/query-view/query-input/__snapshots__/query-input.spec.tsx.snap index e2d965dd86f..c5906e52a2d 100644 --- a/web-console/src/views/query-view/query-input/__snapshots__/query-input.spec.tsx.snap +++ b/web-console/src/views/query-view/query-input/__snapshots__/query-input.spec.tsx.snap @@ -1,5 +1,24 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`query input correctly formats helper HTML 1`] = ` +" +
+
+ COUNT +
+
+
+ Syntax: +
+
COUNT(*)
+
+
+ Description: +
+
Counts the number of things
+
" +`; + exports[`query input matches snapshot 1`] = `
{ const { container } = render(sqlControl); expect(container.firstChild).toMatchSnapshot(); }); + + it('correctly formats helper HTML', () => { + expect( + QueryInput.completerToHtml({ + caption: 'COUNT', + syntax: 'COUNT(*)', + description: 'Counts the number of things', + }), + ).toMatchSnapshot(); + }); }); diff --git a/web-console/src/views/query-view/query-input/query-input.tsx b/web-console/src/views/query-view/query-input/query-input.tsx index 8056c4787d0..030fc833f1b 100644 --- a/web-console/src/views/query-view/query-input/query-input.tsx +++ b/web-console/src/views/query-view/query-input/query-input.tsx @@ -106,11 +106,17 @@ export class QueryInput extends React.PureComponent { if (item.meta === 'function') { - const functionName = item.caption.slice(0, -2); - item.docHTML = ` + item.docHTML = QueryInput.completerToHtml(item); + } + }, + }); + } + + static completerToHtml(item: any) { + return `
- ${escape(functionName)} + ${escape(item.caption)}

@@ -123,9 +129,6 @@ export class QueryInput extends React.PureComponent
${escape(item.description)}
`; - } - }, - }); } static getDerivedStateFromProps(props: QueryInputProps, state: QueryInputState) {