import { describe, it } from '@ephox/bedrock-client'; import { Arr } from '@ephox/katamari'; import { McEditor } from '@ephox/wrap-mcagar'; import { assert } from 'chai'; import Editor from 'tinymce/core/api/Editor'; import { RawEditorOptions } from 'tinymce/core/api/OptionTypes'; import { PasteBin } from 'tinymce/core/paste/PasteBin'; interface TestCase { readonly label: string; readonly content: string; readonly result: string; } describe('browser.tinymce.core.paste.PasteBin', () => { const cases: TestCase[] = [ { label: 'TINY-1162: testing nested paste bins', content: '
' + '
a
' + '
b
' + '
', result: '
a
b
' }, { label: 'TINY-1162: testing adjacent paste bins', content: '
' + '

a

b

' + '
' + '

c

' + '
', result: '

a

b

c

' } ]; const pCreateEditorFromSettings = (settings: RawEditorOptions = {}, html?: string) => McEditor.pFromHtml(html, { ...settings, add_unload_trigger: false, indent: false, base_url: '/project/tinymce/js/tinymce' }); const pCreateEditorFromHtml = (html: string, settings: RawEditorOptions) => pCreateEditorFromSettings(settings, html); const assertCases = (editor: Editor, cases: TestCase[]) => { const pasteBin = PasteBin(editor); Arr.each(cases, (c) => { editor.getBody().appendChild(editor.dom.createFragment(c.content)); assert.equal(pasteBin.getHtml(), c.result, c.label); pasteBin.remove(); }); }; it('TBA: Create editor from settings and test nested and adjacent paste bins', async () => { const editor = await pCreateEditorFromSettings(); assertCases(editor, cases); McEditor.remove(editor); }); // TINY-1208/TINY-1209: same cases, but for inline editor it('TBA: Create editor from html and test nested and adjacent paste bins', async () => { const editor = await pCreateEditorFromHtml('
some text
', { inline: true }); assertCases(editor, cases); McEditor.remove(editor); }); });