const convertFromHTML = (html_string, config) => { const options = { ...DEFAULT_CONFIG, ...config, }; const {DOMBuilder, blockRenderMap, experimentalTreeDataSupport} = options; jest.resetModules(); toggleExperimentalTreeDataSupport(experimentalTreeDataSupport); return convertFromHTMLToContentBlocks( html_string, DOMBuilder, blockRenderMap, ); };
test('highlighted text should be recognized and considered styled characters', () => { const blocks = convertFromHTMLToContentBlocks(`<mark>test</mark>`); expect(blocks.contentBlocks).toMatchSnapshot(); });
test('img with data protocol should be correctly parsed', () => { const blocks = convertFromHTMLToContentBlocks( `<img src="${IMAGE_DATA_URL}">`, ); expect(blocks.contentBlocks[0].text).toMatchSnapshot(); });
test('img with role presentation should not be rendered', () => { const blocks = convertFromHTMLToContentBlocks( `<img src="${IMAGE_DATA_URL}" role="presentation">`, ); expect(blocks.contentBlocks).toMatchSnapshot(); });
test('img with http protocol should have camera emoji content', () => { const blocks = convertFromHTMLToContentBlocks( '<img src="http://www.facebook.com">', ); expect(blocks.contentBlocks[0].text).toMatchSnapshot(); });