import { context, describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/media/Plugin'; describe('browser.tinymce.plugins.media.core.MediaAlignmentTest', () => { const hook = TinyHooks.bddSetupLight({ plugins: [ 'media' ], toolbar: 'media', base_url: '/project/tinymce/js/tinymce' }, [ Plugin ]); const testCommand = (cmd: string) => (inputHtml: string, expectedHtml: string) => { const editor = hook.editor(); editor.setContent(inputHtml); TinySelections.select(editor, '.mce-preview-object,[data-ephox-embed-iri]', []); editor.execCommand(cmd); TinyAssertions.assertContent(editor, expectedHtml); }; const testAlignLeft = testCommand('JustifyLeft'); const testAlignCenter = testCommand('JustifyCenter'); const testAlignRight = testCommand('JustifyRight'); context('apply alignment to video elements', () => { it('TINY-8687: align video element without styles to the left', () => testAlignLeft( '

', '

' )); it('TINY-8687: align video element without styles to the center', () => testAlignCenter( '

', '

' )); it('TINY-8687: align video element without styles to the right', () => testAlignRight( '

', '

' )); it('TINY-8687: aligning a video element with styles to the left should retain existing styles', () => testAlignLeft( '

', '

' )); }); context('apply alignment to ephox embed elements', () => { it('TINY-8687: align ephox embed element without styles to the left', () => testAlignLeft( '
', '
' )); it('TINY-8687: align ephox embed element without styles to the center', () => testAlignCenter( '
', '
' )); it('TINY-8687: align ephox embed element without styles to the right', () => testAlignRight( '
', '
' )); }); context('remove alignment from video', () => { it('TINY-8687: remove align left from video element without styles', () => testAlignLeft( '

', '

' )); it('TINY-8687: remove align center from video element without styles', () => testAlignCenter( '

', '

' )); it('TINY-8687: remove align right from video element without styles', () => testAlignRight( '

', '

' )); it('TINY-8687: removing alignment left from a video element with styles should retain the existing styles', () => testAlignLeft( '

', '

' )); }); });