<commit_before><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Zepto DOM unit tests</title>
  <script src="../src/polyfill.js"></script>
  <script src="../src/zepto.js"></script>
  <script src="../src/form.js"></script>
  <script src="../vendor/evidence.js"></script>
  </style>
</head>
<body>
  <h1>Zepto DOM unit tests</h1>
  <p>
    See the browser console for results.
  </p>

  <form id="login_form">
    <input name="email" value="<EMAIL>" />
    <input name="password" value="<PASSWORD>" /><br>
    <input name="unchecked_hasValue" value="myValue" type="checkbox">
    <input name="unchecked_noValue" type="checkbox">
    <input name="checked_hasValue" checked="checked" value="myValue" type="checkbox">
    <input name="checked_noValue" checked="checked" type="checkbox">

    <input type="radio" name="radio1" value="r1">
    <input type="radio" name="radio1" checked="checked" value="r2">
    <input type="radio" name="radio1" value="r3">

    <select name="selectbox">
        <option value="selectopt1">select1</option>
        <option value="selectopt2">select2</option>
        <option value="selectopt3">select3</option>
    </select>
  </form>

  <script>
    var isObjectEquals = function (obj1, obj2) {
      for (key in obj1) {
        switch( typeof( obj1[key] ) ) {
          case 'object':
            if ( !isObjectEquals( obj1[key], obj2[key] ) ) {
              return false
            };
            break;

          case 'function':
            if (
                 typeof( obj2[key] ) == 'undefined' ||
                 ( obj1[key].toString() != obj2[key].toString() )
               ) {
              return false;
            };
            break;

          default:
            if ( obj1[key] != obj2[key] ) {
              return false;
            }
        }
      }

      for (key in obj2) {
        if (typeof( obj1[key] ) == 'undefined') {
          return false;
        }
      }

      return true;
    }

    Evidence.Assertions.assertEqualObject = function(expected, actual, message) {
      this._assertExpression(
        isObjectEquals(expected, actual),
        message || 'Failed assertion.',
        'Expected %o, got %o.', expected, actual
      );
    }

    Evidence.TestCase.extend('ZeptoTest', {

      testSerializeArray: function (t) {
        var loginForm = $('#login_form');

        t.assertEqual(Function, loginForm.serializeArray.constructor);
        t.assertEqual(6, loginForm.serializeArray().length);
        t.assertEqualObject(
          [
              { name: 'email', value: '<EMAIL>' },
              { name: 'password', value: '<PASSWORD>' },
              { name: 'checked_hasValue', value: 'myValue' },
              { name: 'checked_noValue', value: 'on' },
              { name: 'radio1', value: 'r2' },
              { name: 'selectbox', value: 'selectopt1' }

          ],
          loginForm.serializeArray()
        );
      },

      testSerialize: function (t) {
        var loginForm = $('#login_form');

        t.assertEqual(Function, loginForm.serialize.constructor);
        t.assertEqual( 'string', typeof loginForm.serialize() );

        t.assertEqual( 'email=koss%40nocorp.me&password=<PASSWORD>&checked_hasValue=myValue&checked_noValue=on&radio1=r2&selectbox=selectopt1', loginForm.serialize() );
      },

      testFormSubmit: function (t) {
        var formSubmitted = false;
        $('#login_form').get(0).submit = function (e) {
          formSubmitted = true;
          e.preventDefault();
        };
        $('#login_form').submit();
        t.assert(formSubmitted);

        var eventTriggired = false;
        $('#login_form').submit(function (e) {
          eventTriggired = true;
          e.preventDefault();
        });
        $('#login_form').submit();
        t.assert(eventTriggired);
      }

    });
  </script>
</body>
</html>
<commit_msg>fix submit() test in form.html<commit_after><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Zepto DOM unit tests</title>
  <script src="../src/polyfill.js"></script>
  <script src="../src/zepto.js"></script>
  <script src="../src/event.js"></script>
  <script src="../src/form.js"></script>
  <script src="../vendor/evidence.js"></script>
  </style>
</head>
<body>
  <h1>Zepto DOM unit tests</h1>
  <p>
    See the browser console for results.
  </p>

  <form id="login_form">
    <input name="email" value="<EMAIL>" />
    <input name="password" value="<PASSWORD>" /><br>
    <input name="unchecked_hasValue" value="myValue" type="checkbox">
    <input name="unchecked_noValue" type="checkbox">
    <input name="checked_hasValue" checked="checked" value="myValue" type="checkbox">
    <input name="checked_noValue" checked="checked" type="checkbox">

    <input type="radio" name="radio1" value="r1">
    <input type="radio" name="radio1" checked="checked" value="r2">
    <input type="radio" name="radio1" value="r3">

    <select name="selectbox">
        <option value="selectopt1">select1</option>
        <option value="selectopt2">select2</option>
        <option value="selectopt3">select3</option>
    </select>
  </form>

  <script>
    var isObjectEquals = function (obj1, obj2) {
      for (key in obj1) {
        switch( typeof( obj1[key] ) ) {
          case 'object':
            if ( !isObjectEquals( obj1[key], obj2[key] ) ) {
              return false
            };
            break;

          case 'function':
            if (
                 typeof( obj2[key] ) == 'undefined' ||
                 ( obj1[key].toString() != obj2[key].toString() )
               ) {
              return false;
            };
            break;

          default:
            if ( obj1[key] != obj2[key] ) {
              return false;
            }
        }
      }

      for (key in obj2) {
        if (typeof( obj1[key] ) == 'undefined') {
          return false;
        }
      }

      return true;
    }

    Evidence.Assertions.assertEqualObject = function(expected, actual, message) {
      this._assertExpression(
        isObjectEquals(expected, actual),
        message || 'Failed assertion.',
        'Expected %o, got %o.', expected, actual
      );
    }

    Evidence.TestCase.extend('ZeptoTest', {

      testSerializeArray: function (t) {
        var loginForm = $('#login_form');

        t.assertEqual(Function, loginForm.serializeArray.constructor);
        t.assertEqual(6, loginForm.serializeArray().length);
        t.assertEqualObject(
          [
              { name: 'email', value: '<EMAIL>' },
              { name: 'password', value: '<PASSWORD>' },
              { name: 'checked_hasValue', value: 'myValue' },
              { name: 'checked_noValue', value: 'on' },
              { name: 'radio1', value: 'r2' },
              { name: 'selectbox', value: 'selectopt1' }

          ],
          loginForm.serializeArray()
        );
      },

      testSerialize: function (t) {
        var loginForm = $('#login_form');

        t.assertEqual(Function, loginForm.serialize.constructor);
        t.assertEqual( 'string', typeof loginForm.serialize() );

        t.assertEqual( 'email=koss%40noc<EMAIL>.me&password=<PASSWORD>&checked_hasValue=myValue&checked_noValue=on&radio1=r2&selectbox=selectopt1', loginForm.serialize() );
      },

      testFormSubmit: function (t) {
        var eventTriggered = false;
        $('#login_form').submit(function (e) {
          eventTriggered = true;
          e.preventDefault();
        });
        $('#login_form').submit();
        t.assert(eventTriggered);
      }

    });
  </script>
</body>
</html>

{'fraction_non_alphanumeric': 0.1623119556611243, 'fraction_numerical': 0.009897070467141725, 'mean_word_length': 2.278114186851211, 'pattern_counts': {'":': 0, '<': 106, '<?xml version=': 0, '>': 106, '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': '2524362', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2256, 'n_words': 449}