ModuleLoader.require(["tinymce/fmt/Hooks"], function(Hooks) { module("tinymce.fmt.Hooks", { setupModule: function() { QUnit.stop(); tinymce.init({ selector: "textarea", add_unload_trigger: false, disable_nodechange: true, skin: false, entities: 'raw', indent: false, init_instance_callback: function(ed) { editor = ed; QUnit.start(); } }); } }); test('pre - postProcessHook', function() { function assertPreHook(setupHtml, setupSelection, expected) { editor.getBody().innerHTML = setupHtml; Utils.setSelection.apply(Utils, setupSelection); Hooks.postProcess('pre', editor); equal(editor.getContent(), expected); } assertPreHook( '
a
b', ['pre:nth-child(1)', 0, 'pre:nth-child(2)', 1], '
a' ); assertPreHook( '
b
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' ); assertPreHook( '
b
c
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