import { rfc002Source } from './shared';
import { hoist } from '../hoist';
import { translateTreeTest } from './utils';
import { TNodeImpl } from '../../tree/tree-types';
function makeTTree(source: string) {
return hoist(translateTreeTest(source));
}
describe('hoist function', () => {
it('should comply with RFC002 example (hoisting) ', () => {
const hoistedTree = makeTTree(rfc002Source);
expect(hoistedTree).toMatchSnapshot();
});
it('should hoist multiple blocks', () => {
const hoistedTree = makeTTree('Hello {
const tdoc = makeTTree(
''
);
expect(tdoc).toMatchSnapshot();
});
it('should preserve void text elements', () => {
const tbr = makeTTree('
');
expect(tbr).toMatchSnapshot();
});
it('should preserve text of encompassing blocks', () => {
const tdoc = makeTTree(
'');
expect(tspan).toMatchSnapshot();
const tstrong = tspan.children[0].children[0];
expect(tstrong.tagName).toBe('strong');
expect(tstrong.parent).toBeDefined();
expect(tstrong.parent!.tagName).toBe('span');
});
it('should not hoist blocks', () => {
const tdiv = makeTTree('