var $fixture = $( "#qunit-fixture" );

function simulateTyping(string, input) {
    for (var i = 0; i < string.length; i++) {
        input.val( input.val() + string.charAt(i));
        input.keyup();
    };
}

QUnit.test("default word limit reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\"></input>" );
    var input = $('#test-input');

    //init textlimit with no options
    input.textlimit();

    var string = "One Two Three Four Five Six Seven Eight Nine Ten Eleven";

    simulateTyping(string, input);

    //should strip "Eleven"
    assert.equal( input.val(), "One Two Three Four Five Six Seven Eight Nine Ten ", "Passed!" );
});

QUnit.test("default word limit not reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\"></input>" );
    var input = $('#test-input');

    //init textlimit with no options
    input.textlimit();

    var string = "One Two Three Four Five Six"

    simulateTyping(string, input);

    //should strip nothing
    assert.equal( input.val(), "One Two Three Four Five Six", "Passed!" );
});

QUnit.test("option word limit reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\"></input>" );
    var input = $('#test-input');

    //init textlimit with wordlimit of 5
    input.textlimit({wordlimit: 5});

    var string = "One Two Three Four Five Six";

    simulateTyping(string, input);

    //should strip everything after "Five "
    assert.equal( input.val(), "One Two Three Four Five ", "Passed!" );
});

QUnit.test("option word limit not reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\"></input>" );
    var input = $('#test-input');

    //init textlimit with wordlimit of 5
    input.textlimit({wordlimit: 5});

    var string = "One Two Three";

    simulateTyping(string, input);

    //should strip everything after "Five "
    assert.equal( input.val(), "One Two Three", "Passed!" );
});

QUnit.test("data attribute word limit reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\" data-wordlimit=\"5\"></input>" );
    var input = $('#test-input');

    //init textlimit with no options
    input.textlimit();

    var string = "One Two Three Four Five Six Seven Eight Nine Ten Eleven";

    simulateTyping(string, input);

    assert.equal( input.data('wordlimit'), 5, "data.wordlimit = 5" )

    //should strip "Eleven"
    assert.equal( input.val(), "One Two Three Four Five ", "Passed!");
});

QUnit.test("data attribute word limit not reached", function(assert) {

    //create test element
    $fixture.prepend( "<input type=\"text\" id=\"test-input\" value=\"\" data-wordlimit=\"5\"></input>" );
    var input = $('#test-input');

    //init textlimit with no options
    input.textlimit();

    var string = "One Two Three"

    simulateTyping(string, input);

    //should strip nothing
    assert.equal( input.val(), "One Two Three", "Passed!" );
});
@@ -2561,100 +2561,46 @@
     
-assert.equal( input.data('wordlimit'), 5, %22data.wordlimit = 5%22 )%0A%0A    //should strip %22Eleven
+//should strip everything after %22Five 
 %22%0A  

Test fixes