(function() { module("tinymce.plugins.TextPattern", { setupModule: function() { QUnit.stop(); tinymce.init({ selector: 'textarea', add_unload_trigger: false, skin: false, indent: false, plugins: "textpattern", init_instance_callback: function(ed) { window.editor = ed; QUnit.start(); } }); }, teardown: function() { delete editor.settings.textpattern_patterns; } }); test('Italic format on single word using space', function() { editor.setContent('

*abc*\u00a0

'); Utils.setSelection('p', 6); editor.fire('keyup', {keyCode: 32}); equal( editor.getContent(), '

abc 

' ); }); test('Bold format on single word using space', function() { editor.setContent('

**abc**\u00a0

'); Utils.setSelection('p', 8); editor.fire('keyup', {keyCode: 32}); equal( editor.getContent(), '

abc 

' ); }); test('Bold format on multiple words using space', function() { editor.setContent('

**abc 123**\u00a0

'); Utils.setSelection('p', 12); editor.fire('keyup', {keyCode: 32}); equal( editor.getContent(), '

abc 123 

' ); }); test('Bold format on single word using enter', function() { editor.setContent('

**abc**

'); Utils.setSelection('p', 7); editor.fire('keydown', {keyCode: 13}); equal( editor.getContent(), '

abc

 

' ); }); test('H1 format on single word node using enter', function() { editor.setContent('

#abc

'); Utils.setSelection('p', 4); editor.fire('keydown', {keyCode: 13}); equal( editor.getContent(), '

abc

 

' ); }); test('OL format on single word node using enter', function() { editor.setContent('

1. abc

'); Utils.setSelection('p', 6); editor.fire('keydown', {keyCode: 13}); equal( editor.getContent(), '
  1. abc
' ); }); test('UL format on single word node using enter', function() { editor.setContent('

* abc

'); Utils.setSelection('p', 5); editor.fire('keydown', {keyCode: 13}); equal( editor.getContent(), '' ); }); test('getPatterns/setPatterns', function() { editor.plugins.textpattern.setPatterns([ {start: '#', format: 'h1'}, {start: '##', format: 'h2'}, {start: '###', format: 'h3'} ]); deepEqual( editor.plugins.textpattern.getPatterns(), [ { "format": "h3", "start": "###" }, { "format": "h2", "start": "##" }, { "format": "h1", "start": "#" } ] ); }); })();