import React from 'react';
import FieldMessages from '../../../ui/ConfigPanel/FieldMessages';
import { IntlProvider } from 'react-intl';
import { mount } from 'enzyme';
function mountMessage({ description }: { description: string }) {
return mount(
,
);
}
function findHTML(wrapper: any) {
const div = wrapper.find('Description div');
const children = div.children();
if (children.length) {
return children;
}
return div.text();
}
describe('Field Messages', () => {
it(' should support a plaintext description', async () => {
const description = 'my description';
const wrapper = mountMessage({ description });
expect(findHTML(wrapper)).toMatchSnapshot();
});
it(' should support bold, italic, strong, em and code tags', async () => {
const description =
'my description that has code and strong emphasis';
const wrapper = mountMessage({ description });
expect(findHTML(wrapper)).toMatchSnapshot();
});
it(' should drop unsafe/unspecified tags', async () => {
const wrapper = mountMessage({
description: `
my
description that has bad code and emphasis on malformed tags`,
});
expect(findHTML(wrapper)).toMatchSnapshot();
});
});