<commit_before>describe('Search Widget', function() {

    var searchWidget;

    function performSearch() {

        searchWidget.find('.tsbar-widget button').click();
        searchWidget.find("input[type='text']").val('test');
        searchWidget.find("input[value='Find']").click();
    }
    
    beforeEach(function () {

        tsbar.initSearchWidget(window, $);
        tsbar.clear();
        searchWidget = tsbar.searchWidget;
    });

    afterEach(function () {

        $('#sandbox').html('');
    });

    describe('Search Widget creation', function() {

        it('should contain an input text field', function() {

            expect(searchWidget.find("input[type='text']").length).toEqual(1);
        });

        it('should contain a find button', function() {

            expect(searchWidget.find("input[value='Find']").length).toEqual(1);
        });

        it('should contain a clear button', function() {

            expect(searchWidget.find("input[value='Clear']").length).toEqual(1);
        });

        it('should contain a div area for search results', function() {

            expect(searchWidget.find("div:not('.tsbar-popup')").length).toEqual(1);
        });

    });

    describe('Performing searches', function() {

        beforeEach(function () {

            tsbar.define('left', searchWidget);
            var toolbar = tsbar.render();
            $('#sandbox').append(toolbar);
        });

        //TODO: Split into 2 tests - one for search results and one for clearing the results.
        it('should render search results then clear the search results area and search query text', function() {

            runs(function() {

                performSearch();
            });

            waitsFor(function () {

                return searchWidget.find("div:not('.tsbar-popup')").html() ===
                '<div id="container"><div>some search results</div></div>';

            }, 'the search results to appear after the search button was clicked', 500);

            runs(function() {

                searchWidget.find("input[value='Clear']").trigger('click');
            });

            waitsFor(function() {
                return searchWidget.find("div:not('.tsbar-popup'):empty").length === 1;
            }, 'the search results to clear after the clear button was clicked', 500);

            waitsFor(function() {
                return searchWidget.find("input[type='text']").val() === '';
            }, 'the query text to clear after the clear button was clicked', 500);
        });
    });
});
<commit_msg>Change the tests to match what the search box needs to do.<commit_after>describe('Search Widget', function() {

    var searchWidget;

    function performSearch() {

        searchWidget.find("input[type='text']").focus().val('test').trigger("input");
    }
    
    beforeEach(function () {

        tsbar.initSearchWidget(window, $);
        tsbar.clear();
        searchWidget = tsbar.searchWidget;
    });

    afterEach(function () {

        $('#sandbox').html('');
    });

    describe('Search Widget creation', function() {

        it('should contain an input text field', function() {

            expect(searchWidget.find("input[type='text']").length).toEqual(1);
        });

        it('should contain a clear button', function() {

            expect(searchWidget.find("button.clear").length).toEqual(1);
        });

    });

    describe('interacting with search widget', function() {

        beforeEach(function () {

            tsbar.define('left', searchWidget);
            var toolbar = tsbar.render();
            $('#sandbox').append(toolbar);
        });

        //TODO: Split into 2 tests - one for search results and one for clearing the results.
        it('should render search results then clear the search results area and search query text', function() {

            runs(function() {
                performSearch();
            });

            waitsFor(function () {
                return searchWidget.find("form").hasClass("inuse");
            }, 'the search form to have the inuse class', 200);

			waitsFor(function() {
				return searchWidget.find("button.clear").is(":visible");
			}, 'clear button should appear now text has been entered', 200);

            runs(function() {
				searchWidget.find("button.clear").trigger('click');
            });

            waitsFor(function() {
                return searchWidget.find("input[type='text']").val() === '';
            }, 'the search box to clear after the clear button was clicked', 200);

            waitsFor(function() {
                return searchWidget.find("button.clear").is(":hidden");
            }, 'the clear button to be invisble now search query removed', 200);

			runs(function() {
				searchWidget.find("input[type='text']").blur();
			});
			
			waitsFor(function() {
				return !searchWidget.find("form").hasClass("inuse");
			}, 'the inuse class to be removed from the form', 200);
        });
    });
});

{'fraction_non_alphanumeric': 0.15556888622275544, 'fraction_numerical': 0.0065986802639472104, 'mean_word_length': 2.3525469168900806, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '3993248', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1261, 'n_words': 308}