<commit_before>/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false, console:false*/
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
/*global JSON:false */
/*global runJQBVTest:false, attachJqbv:false, numInJQBVTest:false, startJQBVTestQueue:false, pushJQBVTest:false, extractEvents:false*/
/*jshint multistr: true */
(function($) {

    /*
     ======== A Handy Little QUnit Reference ========
     http://docs.jquery.com/QUnit
     
     Test methods:
     - expect(numAssertions)
     - stop(increment)
     - start(decrement)
     Test assertions:
     - ok(value, [message])
     - equal(actual, expected, [message])
     - notEqual(actual, expected, [message])
     - deepEqual(actual, expected, [message])
     - notDeepEqual(actual, expected, [message])
     - strictEqual(actual, expected, [message])
     - notStrictEqual(actual, expected, [message])
     - raises(block, [expected], [message])
     */

    module('jqBootstrapValidation', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-email-email='email'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
            this.elems = $("#qunit-fixture").children();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is chainable', 1, function() {
        // Not a bad test to run on collection methods.
        strictEqual(this.elems.jqBootstrapValidation(), this.elems, 'should be chaninable');
    });

    test('tidies up events on destroy', 0, function () {
        var $input = $("#qunit-fixture input");
        $input.jqBootstrapValidation("destroy");
        var inputEvents = extractEvents($input);
        var $form = $input.parents("form").first();
        var formEvents = extractEvents($form);
        // do something to make sure the events are all removed properly. should they just be 'empty'?
    });

//    test("responds to jqbv", 1, function() {
//        strictEqual(this.elems.jqbv(), this.elems, "should register jqbv function");
//    });



    module('email field', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-email-email='email'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {
        runJQBVTest("", [], [], [], []);
    });
    test('accepts valid', 5 * numInJQBVTest, function() {
        $([
            'customer/department=<EMAIL>',
            '$A<EMAIL>',
            '!def!xyz%<EMAIL>',
            <EMAIL>',
            '<EMAIL>'
        ]).each(function (i, el) {
            runJQBVTest(el, ["success"], [], [], []);
        });
    });
    test('rejects invalid', 3 * numInJQBVTest, function() {
        runJQBVTest("not an email", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        runJQBVTest("not@<EMAIL>", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        runJQBVTest("<EMAIL>", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
    });

    module('email field (sniffed)', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='email'\
                                name='input'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {
        runJQBVTest("", [], [], [], []);
    });
    test('accepts valid', 1 * numInJQBVTest, function() {
        runJQBVTest("<EMAIL>", ["success"], [], [], []);
    });
    test('rejects invalid', 3 * numInJQBVTest, function() {
        runJQBVTest("not an email", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        runJQBVTest("not@anemail", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        runJQBVTest("<EMAIL>", ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
    });

    module('number field', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-number-number='number'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {<commit_msg>trying out easier test format<commit_after>/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false, console:false*/
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
/*global JSON:false */
/*global runJQBVTest:false, attachJqbv:false, numInJQBVTest:false, startJQBVTestQueue:false, pushJQBVTest:false, extractEvents:false*/
/*jshint multistr: true */
(function($) {

    /*
     ======== A Handy Little QUnit Reference ========
     http://docs.jquery.com/QUnit
     
     Test methods:
     - expect(numAssertions)
     - stop(increment)
     - start(decrement)
     Test assertions:
     - ok(value, [message])
     - equal(actual, expected, [message])
     - notEqual(actual, expected, [message])
     - deepEqual(actual, expected, [message])
     - notDeepEqual(actual, expected, [message])
     - strictEqual(actual, expected, [message])
     - notStrictEqual(actual, expected, [message])
     - raises(block, [expected], [message])
     */

    module('jqBootstrapValidation', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-email-email='email'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
            this.elems = $("#qunit-fixture").children();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is chainable', 1, function() {
        // Not a bad test to run on collection methods.
        strictEqual(this.elems.jqBootstrapValidation(), this.elems, 'should be chaninable');
    });

    test('tidies up events on destroy', 0, function () {
        var $input = $("#qunit-fixture input");
        $input.jqBootstrapValidation("destroy");
        var inputEvents = extractEvents($input);
        var $form = $input.parents("form").first();
        var formEvents = extractEvents($form);
        // do something to make sure the events are all removed properly. should they just be 'empty'?
    });

//    test("responds to jqbv", 1, function() {
//        strictEqual(this.elems.jqbv(), this.elems, "should register jqbv function");
//    });



    module('email field', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-email-email='email'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {
        runJQBVTest("", [], [], [], []);
    });
    
    (function () {
      var validEmails = [
        'customer/department=<EMAIL>',
        <EMAIL>',
        '!def!xyz%<EMAIL>',
        <EMAIL>',
        '<EMAIL>',
        '\u2019test\u2019@<EMAIL>.<EMAIL>'
      ];
      test('accepts valid', validEmails.length * numInJQBVTest, function() {
          $(validEmails).each(function (i, el) {
              runJQBVTest(el, ["success"], [], [], []);
          });
      });
    })();
    
    (function () {
      var invalidEmails = [
        "not an email",
        "not@anemail",
        "<EMAIL>",
        "@."
      ];
      
      test('rejects invalid', invalidEmails.length * numInJQBVTest, function() {
        $(invalidEmails).each(function (i, el) {
            runJQBVTest(el, ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        });
      });
    })();

    module('email field (sniffed)', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='email'\
                                name='input'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {
        runJQBVTest("", [], [], [], []);
    });
    
    (function () {
      var validEmails = [
        'customer/department=<EMAIL>',
        <EMAIL>',
        '!def!xyz%abc<EMAIL>',
        <EMAIL>',
        '<EMAIL>',
        '\u2019<EMAIL>\<EMAIL>'
      ];
      test('accepts valid', validEmails.length * numInJQBVTest, function() {
          $(validEmails).each(function (i, el) {
              runJQBVTest(el, ["success"], [], [], []);
          });
      });
    })();
    
    (function () {
      var invalidEmails = [
        "not an email",
        "<EMAIL>",
        "<EMAIL>",
        "@."
      ];
      
      test('rejects invalid', invalidEmails.length * numInJQBVTest, function() {
        $(invalidEmails).each(function (i, el) {
            runJQBVTest(el, ["warning"], ["error"], ["Not a valid email address"], ["Not a valid email address"]);
        });
      });
    })();

    module('number field', {
        setup: function() {
            $("#qunit-fixture").append($("\
                <form class='form-horizontal' novalidate>\
                    <div class='control-group'>\
                        <label class='control-label'>Email address</label>\
                        <div class='controls'>\
                            <input\
                                type='text'\
                                name='input'\
                                data-validation-number-number='number'\
                            />\
                        </div>\
                    </div>\
                    <div class='form-actions'>\
                        <button type='submit' class='btn btn-primary'>\
                            Test Validation <i class='icon-ok icon-white'></i>\
                        </button>\
                    </div>\
                </form>\
            "));
            attachJqbv();
        },
        teardown: function() {
            $("#qunit-fixture").empty();
        }
    });

    test('is optional', 1 * numInJQBVTest, function() {
{'fraction_non_alphanumeric': 0.1602547770700637, 'fraction_numerical': 0.0017834394904458599, 'mean_word_length': 1.392351058966936, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3085453', 'n_tokens_mistral': 4271, 'n_tokens_neox': 4038, 'n_words': 830}