( function ( $ ) { 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 {int} options.start Starting char for selection * @param {int} 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, options, text, selected, tests = 1; if ( opt.after.selected !== null ) { tests++; } QUnit.expect( tests ); $textarea = $( '