( function () { var caretSample, sig = { pre: '--~~~~' }, bold = { pre: '\'\'\'', peri: 'Bold text', post: '\'\'\'' }, h2 = { pre: '== ', peri: 'Heading 2', post: ' ==', regex: /^(\s*)(={1,6})(.*?)\2(\s*)$/, regexReplace: '$1==$3==$4', ownline: true }, ulist = { pre: '* ', peri: 'Bulleted list item', post: '', ownline: true, splitlines: true }; QUnit.module( 'jquery.textSelection', QUnit.newMwEnvironment() ); /** * Test factory for $.fn.textSelection( 'encapsulateText' ) * * @param {Object} options Associative configuration array * @param {string} options.description Description * @param {string} options.input Input * @param {string} options.output Output * @param {number} options.start Starting char for selection * @param {number} options.end Ending char for selection * @param {Object} options.params Additional parameters for $().textSelection( 'encapsulateText' ) */ function encapsulateTest( options ) { var opt = $.extend( { description: '', before: {}, after: {}, replace: {} }, options ); opt.before = $.extend( { text: '', start: 0, end: 0 }, opt.before ); opt.after = $.extend( { text: '', selected: null }, opt.after ); QUnit.test( opt.description, function ( assert ) { var $textarea, start, end, opts, text, selected; $textarea = $( '