import { describe, it } from '@ephox/bedrock-client'; import { LegacyUnit, TinyAssertions, TinyHooks } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import * as Hooks from 'tinymce/core/fmt/Hooks'; describe('browser.tinymce.core.fmt.HooksTest', () => { const hook = TinyHooks.bddSetupLight({ add_unload_trigger: false, disable_nodechange: true, entities: 'raw', indent: false, base_url: '/project/tinymce/js/tinymce' }, []); it('pre - postProcessHook', () => { const editor = hook.editor(); const assertPreHook = (setupHtml: string, setupSelection: [ string, number, string, number ], expected: string) => { editor.getBody().innerHTML = setupHtml; LegacyUnit.setSelection(editor, ...setupSelection); Hooks.postProcess('pre', editor); TinyAssertions.assertContent(editor, expected); }; assertPreHook( '
a
b
', [ 'pre:nth-child(1)', 0, 'pre:nth-child(2)', 1 ], '
a

b
' ); assertPreHook( '
a
b
', [ 'pre:nth-child(2)', 0, 'pre:nth-child(2)', 1 ], '
a
b
' ); assertPreHook( '
a
b
', [ 'pre:nth-child(2)', 1, 'pre:nth-child(2)', 1 ], '
a
b
' ); assertPreHook( '
a
b
c
', [ 'pre:nth-child(1)', 0, 'pre:nth-child(3)', 1 ], '
a

b

c
' ); assertPreHook( '
a
b
', [ 'pre:nth-child(1)', 0, 'pre:nth-child(1)', 1 ], '
a
b
' ); assertPreHook( '
a

b

c
', [ 'pre:nth-child(1)', 0, 'pre:nth-child(3)', 1 ], '
a

b

c
' ); assertPreHook( '
a
b

c

d
e
', [ 'pre:nth-child(1)', 0, 'pre:nth-child(5)', 1 ], '
a

b

c

d

e
' ); }); });