<commit_before><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Javascript tests</title>
    <link rel="stylesheet" href="../../../superlists/static/tests/qunit.css">
</head>

<body>
    <div id="qunit"></div>
    <div id="qunit-fixture">
        <form>
            <input name="text" />
            <div class="has-error">Error text</div>
        </form>
    </div>

    <script src="http://code.jquery.com/jquery.min.js"></script>
    <script src="../../../superlists/static/tests/qunit.js"></script>
    <script src="../list.js"></script>
    <script>
/*global $, test, equal */

test("errors should be hidden on keypress", function() {
    $('input').trigger('keypress');
    equal($('.has-error').is(':visible'), false);
});
test("errors not be hidden unless there is a keypress", function() {
    equal($('.has-error').is(':visible'), true);
});

    </script>

</body>
</html><commit_msg>Chapter 15, setting up the mock testing<commit_after><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Javascript tests</title>
    <link rel="stylesheet" href="../../../superlists/static/tests/qunit.css">
</head>

<body>
    <div id="qunit"></div>
    <div id="qunit-fixture">
        <a id="id_login">Sign in</a>
    </div>

    <script src="http://code.jquery.com/jquery.min.js"></script>
    <script src="../../../superlists/static/tests/qunit.js"></script>
    <script src="../accounts.js"></script>
    <script>
/*global $, test, equal, sinon, Superlists */

test("initialize binds sign in button to navigator.id.request", function() {
    var requestWasCalled = false;
    var mockRequestFunction = function() { requestWasCalled = true; };
    var mockNavigator = {
        id: {
            request: mockRequestFunction
        }
    };

    Superlists.Accounts.initialize(mockNavigator);

    $('#id_login').trigger('click');

    equal(requestWasCalled, true);
});

    </script>

</body>
</html>
{'fraction_non_alphanumeric': 0.21104231166150672, 'fraction_numerical': 0.0020639834881320948, 'mean_word_length': 3.0144927536231885, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 56, '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': '2735885', 'n_tokens_mistral': 636, 'n_tokens_neox': 616, 'n_words': 126}