import { context, describe, it } from '@ephox/bedrock-client'; import { McEditor, TinyAssertions } from '@ephox/wrap-mcagar'; import { assert } from 'chai'; import Editor from 'tinymce/core/api/Editor'; describe('browser.tinymce.core.init.InitContentBodySelectionTest', () => { const initAndAssertContent = (label: string, html: string, path: number[], offset = 0, extraSettings = {}) => { it(label, async () => { const editor = await McEditor.pFromHtml(``, { menubar: false, toolbar: false, base_url: '/project/tinymce/js/tinymce', ...extraSettings }); TinyAssertions.assertSelection(editor, path, offset, path, offset); assert.isFalse(editor.hasFocus(), `Check editor doesn't have focus`); McEditor.remove(editor); }); }; context('TINY-4139: Paragraph tests', () => { initAndAssertContent('Test p with br', '


', [ 0 ]); initAndAssertContent('Test p', '

Initial Content

', [ 0, 0 ]); initAndAssertContent('Test h1', '

Initial Content

', [ 0, 0 ]); initAndAssertContent('Test p with inline styles', '

Initial Content

', [ 0, 0, 0 ]); initAndAssertContent('Test p with noneditable span', '

Initial Content

', [ 0, 0 ]); initAndAssertContent('Test noneditable p', '

Initial Content

', [ 0 ]); initAndAssertContent('Test cef p', '

Initial Content

', [ 0 ]); }); context('TINY-4139: More complex content tests', () => { initAndAssertContent('Test a (which should be wrapped in a p on init)', 'Initial Content', [ 0, 0, 0 ], 1); initAndAssertContent('Test a in paragraph', '

Initial Content

', [ 0, 0, 0 ], 1); initAndAssertContent('Test list', '', [ 0, 0, 0 ]); initAndAssertContent('Test image (which should be wrapped in a p on init)', 'My alt text', [ 0 ]); initAndAssertContent('Test image in p', '

My alt text

', [ 0 ]); initAndAssertContent('Test table', '
Initial Content
', [ 0, 0, 0, 0, 0 ]); }); context('TINY-4139: div and forced_root_block tests', () => { initAndAssertContent('Test div with br', '

', [ 0 ]); initAndAssertContent('Test div', '
Initial Content
', [ 0, 0 ]); initAndAssertContent('Test div with br with forced_root_block=div', '

', [ 0 ], 0, { forced_root_block: 'div' }); initAndAssertContent('Test div with forced_root_block=div', '
Initial Content
', [ 0, 0 ], 0, { forced_root_block: 'div' }); }); });