Skip to content

Commit

Permalink
Additional unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Apr 2, 2021
1 parent 39acb79 commit 773db56
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/plugins/data/common/field_formats/converters/source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { SourceFormat } from './source';
import { HtmlContextTypeConvert } from '../types';
import { HTML_CONTEXT_TYPE } from '../content_types';
import { stubIndexPatternWithFields } from '../../index_patterns/index_pattern.stub';

describe('Source Format', () => {
let convertHtml: Function;
Expand All @@ -31,4 +32,19 @@ describe('Source Format', () => {
'<span ng-non-bindable>{&quot;foo&quot;:&quot;bar&quot;,&quot;number&quot;:42,&quot;hello&quot;:&quot;&lt;h1&gt;World&lt;/h1&gt;&quot;,&quot;also&quot;:&quot;with \\&quot;quotes\\&quot; or &#39;single quotes&#39;&quot;}</span>'
);
});

test('should render a description list if a field is passed', () => {
const hit = {
foo: 'bar',
number: 42,
hello: '<h1>World</h1>',
also: 'with "quotes" or \'single quotes\'',
};

const indexPattern = { ...stubIndexPatternWithFields, formatHit: (h: string) => h };

expect(convertHtml(hit, { field: 'field', indexPattern, hit })).toMatchInlineSnapshot(
`"<span ng-non-bindable><dl class=\\"source truncate-by-height\\"><dt>foo:</dt><dd>bar</dd> <dt>number:</dt><dd>42</dd> <dt>hello:</dt><dd><h1>World</h1></dd> <dt>also:</dt><dd>with \\"quotes\\" or 'single quotes'</dd> </dl></span>"`
);
});
});

0 comments on commit 773db56

Please sign in to comment.