<commit_before>(function (JSpec) {

    JSpec.describe("jQuery Mu plugin's muSearchForm module", function () {
        describe("#muSearchForm", function () {
            before_each(function () {
                page = sandbox().append(fixture("jquery.mu.searchform"));
                searchOptions = {
                    attachWith:         function (form) {
                        page.find("table").before(form);
                    },
                    loadWith:           function () {
                        return "<span class='searchNotify'>Searching...</span>";
                    },
                    formScope:          page,
                    clearTimeoutWith:   function () {},
                    setTimeoutWith:     function (action) {
                        action();
                        return "1";     /* a fake id */
                    }
                };
            });

            describe("for its layout", function () {
                before_each(function () {
                    page.find("table tr:not(:first)").muSearchForm(searchOptions);
                });

                it("should create a form into user defined location on a page", function () {
                    var form = page.find("table").prev();
                    expect(form[0].tagName).to(equal, "FORM");
                    expect(form.hasClass("muSearchForm")).to(be_true);
                });

                it("should have an input field in the form", function () {
                    var input = page.find("form.muSearchForm input");
                    expect(input.hasClass("muSearchFormInput")).to(be_true);
                });

                it("should have a loader element in the form, initially hidden", function () {
                    var wrapper = page.find("form.muSearchForm > span");
                    expect(wrapper.hasClass("muSearchFormLoader")).to(be_true);
                    expect(wrapper).to(be_hidden);
                    var loader = wrapper.children();
                    expect(loader.hasClass("searchNotify")).to(be_true);
                });
            });

            describe("for its behavior", function () {
                before_each(function () {
                    $.fn.simulateSearch = function (query) {
                        element = $(this);
                        element.val(query);
                        element.trigger("keyup");
                        return element;
                    };
                });

                describe("with expected user options", function () {
                    before_each(function () {
                        page.find("table tr:not(:first)").muSearchForm(searchOptions);
                        input = page.find("input.muSearchFormInput");
                    });

                    it("when searching, should show loader element", function () {
                        var timedActions = [];
                        searchOptions.setTimeoutWith = function (action) {
                            timedActions.push(action);
                        };
                        page.find("form.muSearchForm").remove();
                        page.find("table tr:not(:first)").muSearchForm(searchOptions);
                        input = page.find("input.muSearchFormInput");
                        input.simulateSearch("John");
                        timedActions.pop().call();
                        var wrapper = page.find("form.muSearchForm > span");
                        expect(wrapper.hasClass("muSearchFormLoader")).to(be_true);
                        expect(wrapper).to(be_visible);
                    });
<commit_msg>Rename test context<commit_after>(function (JSpec) {

    JSpec.describe("jQuery Mu plugin's muSearchForm module", function () {
        describe("#muSearchForm", function () {
            before_each(function () {
                page = sandbox().append(fixture("jquery.mu.searchform"));
                searchOptions = {
                    attachWith:         function (form) {
                        page.find("table").before(form);
                    },
                    loadWith:           function () {
                        return "<span class='searchNotify'>Searching...</span>";
                    },
                    formScope:          page,
                    clearTimeoutWith:   function () {},
                    setTimeoutWith:     function (action) {
                        action();
                        return "1";     /* a fake id */
                    }
                };
            });

            describe("for its layout", function () {
                before_each(function () {
                    page.find("table tr:not(:first)").muSearchForm(searchOptions);
                });

                it("should create a form into user defined location on a page", function () {
                    var form = page.find("table").prev();
                    expect(form[0].tagName).to(equal, "FORM");
                    expect(form.hasClass("muSearchForm")).to(be_true);
                });

                it("should have an input field in the form", function () {
                    var input = page.find("form.muSearchForm input");
                    expect(input.hasClass("muSearchFormInput")).to(be_true);
                });

                it("should have a loader element in the form, initially hidden", function () {
                    var wrapper = page.find("form.muSearchForm > span");
                    expect(wrapper.hasClass("muSearchFormLoader")).to(be_true);
                    expect(wrapper).to(be_hidden);
                    var loader = wrapper.children();
                    expect(loader.hasClass("searchNotify")).to(be_true);
                });
            });

            describe("for its behavior", function () {
                before_each(function () {
                    $.fn.simulateSearch = function (query) {
                        element = $(this);
                        element.val(query);
                        element.trigger("keyup");
                        return element;
                    };
                });

                describe("with expected user options and highlighting disabled", function () {
                    before_each(function () {
                        page.find("table tr:not(:first)").muSearchForm(searchOptions);
                        input = page.find("input.muSearchFormInput");
                    });

                    it("when searching, should show loader element", function () {
                        var timedActions = [];
                        searchOptions.setTimeoutWith = function (action) {
                            timedActions.push(action);
                        };
                        page.find("form.muSearchForm").remove();
                        page.find("table tr:not(:first)").muSearchForm(searchOptions);
                        input = page.find("input.muSearchFormInput");
                        input.simulateSearch("John");
                        timedActions.pop().call();
                        var wrapper = page.find("form.muSearchForm > span");
                        expect(wrapper.hasClass("muSearchFormLoader")).to(be_true);
                        expect(wrapper).to(be_visible);
                    });

{'fraction_non_alphanumeric': 0.11708774789459386, 'fraction_numerical': 0.0005433306166802499, 'mean_word_length': 1.2339199029126213, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6254542', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1538, 'n_words': 297}