<commit_before>$(function () {
    var $fixture = $("#qunit-fixture"),
        fileId = 123,
        $container, $fileItem, $filenameDiv;

    module('Filename Click Handler', {
        setup: function() {
            $fixture = $("#qunit-fixture");

            $fixture.append('<div class="testcontainer"></div>');

            $container = $fixture.find('.testcontainer');
            $container.append('<div class="fileitem"></div>');

            $fileItem = $container.find('.fileitem');
            $fileItem.append('<div class="test-file"></div>');

            $filenameDiv = $fileItem.find('.test-file');

            $fileItem[0].qqFileId = fileId;
        }
    });

        test('filename click handler - upload in progress', function () {
            new qq.FilenameClickHandler({
                listElement: $container[0],
                classes: {
                    file: 'test-file'
                },
                onGetName: function() {return "test"},
                onSetName: function(fileId, newName) {},
                onGetUploadStatus: function(fileId) { return qq.status.UPLOADING; }
            });


            helpme.createAndTriggerMouseEvent('click', $filenameDiv[0]);
            equal($container.find('INPUT').length, 0, "should not create input element to change filename, upload already in progress");
        });

    test('filename click handler - file submitted', function () {
        //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
        expect(qq.firefox() ? 4 : 7);

        var origName = "test.foo.bar",
            origNameSansExt = "test.foo",
            newNameSansExt = "blahblah",
            newName = "blahblah.bar",
            $input;

        new qq.FilenameClickHandler({
            listElement: $container[0],
            classes: {
                file: 'test-file'
            },
            onGetName: function() { return origName; },
            onSetName: function(fileId, name) {
                //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
                if (!qq.firefox()) {
                    equal(name, newName, "new name should have the original extension appended");
                }
            },
            onGetUploadStatus: function(fileId) { return qq.status.SUBMITTED; }
        });


        //this shouldn't allow the user to change the filename
        helpme.createAndTriggerMouseEvent('click', $container[0]);

        helpme.createAndTriggerMouseEvent('click', $filenameDiv[0]);

        $input = $container.find('INPUT');

        equal($input.length, 1, "should have created input for changing filename");
        ok($input.is(':visible'), "filename input should be visible");
        ok(!$filenameDiv.is(":visible"), "filename display should not be visible");
        equal($input.val(), origNameSansExt, "filename input should equal original filename sans extension initially");

        $input.val(newNameSansExt);
        $input.blur();

        //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
        if (!qq.firefox()) {
            stop();

            setTimeout(function() {
                ok($filenameDiv.is(":visible"), "filename display should be visible again");
                equal($filenameDiv.text(), newName, "filename display should equal new name with original extension");
                start();
            }, 1000);
        }
    });
});<commit_msg>test: #773 fix unit tests in FF<commit_after>$(function () {
    var $fixture = $("#qunit-fixture"),
        fileId = 123,
        $container, $fileItem, $filenameDiv;

    module('Filename Click Handler', {
        setup: function() {
            $fixture = $("#qunit-fixture");

            $fixture.append('<div class="testcontainer"></div>');

            $container = $fixture.find('.testcontainer');
            $container.append('<div class="fileitem"></div>');

            $fileItem = $container.find('.fileitem');
            $fileItem.append('<div class="test-file"></div>');

            $filenameDiv = $fileItem.find('.test-file');

            $fileItem[0].qqFileId = fileId;
        }
    });

        test('filename click handler - upload in progress', function () {
            new qq.FilenameClickHandler({
                listElement: $container[0],
                classes: {
                    file: 'test-file'
                },
                onGetName: function() {return "test"},
                onSetName: function(fileId, newName) {},
                onGetUploadStatus: function(fileId) { return qq.status.UPLOADING; }
            });


            helpme.createAndTriggerMouseEvent('click', $filenameDiv[0]);
            equal($container.find('INPUT').length, 0, "should not create input element to change filename, upload already in progress");
        });

    test('filename click handler - file submitted', function () {
        //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
        expect(qq.firefox() ? 4 : 7);

        var origName = "test.foo.bar",
            origNameSansExt = "test.foo",
            newNameSansExt = "blahblah",
            newName = "blahblah.bar",
            $input;

        new qq.FilenameClickHandler({
            listElement: $container[0],
            classes: {
                file: 'test-file'
            },
            onGetName: function() { return origName; },
            onSetName: function(fileId, name) {
                //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
                if (!qq.firefox()) {
                    equal(name, newName, "new name should have the original extension appended");
                }
            },
            onGetUploadStatus: function(fileId) { return qq.status.SUBMITTED; }
        });


        //this shouldn't allow the user to change the filename
        helpme.createAndTriggerMouseEvent('click', $container[0]);

        helpme.createAndTriggerMouseEvent('click', $filenameDiv[0]);

        $input = $container.find('INPUT');

        equal($input.length, 1, "should have created input for changing filename");
        ok($input.is(':visible'), "filename input should be visible");
        ok(!$filenameDiv.is(":visible"), "filename display should not be visible");
        equal($input.val(), origNameSansExt, "filename input should equal original filename sans extension initially");

        $input.val(newNameSansExt);
        $input.blur();

        //can't get some of these tests to pass in FF on SauceLabs, even though code being tested seems to work fine during manual testing
        if (!qq.firefox()) {
            stop();

            setTimeout(function() {
                ok($filenameDiv.is(":visible"), "filename display should be visible again");
                equal($filenameDiv.text(), newName, "filename display should equal new name with original extension");
                start();
            }, 0);
        }
    });
});
{'fraction_non_alphanumeric': 0.1259106529209622, 'fraction_numerical': 0.004673539518900344, 'mean_word_length': 2.118731247321046, 'pattern_counts': {'":': 4, '<': 15, '<?xml version=': 0, '>': 15, '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': '2542605', 'n_tokens_mistral': 1933, 'n_tokens_neox': 1818, 'n_words': 538}