<commit_before>describe("TwoStageButton", function () {
    var buttonElement;
    var $buttonElement;
    var twoStageButton;

    beforeEach(function () {
        buttonElement = document.createElement("div");
        document.body.appendChild(buttonElement);

        $buttonElement = $(buttonElement);

        twoStageButton = new TotemUI.TwoStageButton(buttonElement);
    });

    afterEach(function () {
        twoStageButton.dispose();
        document.body.removeChild(buttonElement);
    });

    it("should create its instance and dispose in non-error way", function () {
        expect(twoStageButton).not.toBeNull();
    });

    it("should have correct content after initialization", function () {
        expect($buttonElement.children(":visible").text()).toEqual("");
    })
});<commit_msg>TUI-30: Write unit tests for the TwoStageButton control.<commit_after>describe("TwoStageButton", function () {
    var buttonElement;
    var $buttonElement;
    var twoStageButton;

    beforeEach(function () {
        buttonElement = document.createElement("div");
        document.body.appendChild(buttonElement);

        $buttonElement = $(buttonElement);

        twoStageButton = new TotemUI.TwoStageButton(buttonElement);
    });

    afterEach(function () {
        twoStageButton.dispose();
        document.body.removeChild(buttonElement);
    });

    it("should create its instance and dispose in non-error way", function () {
        expect(twoStageButton).not.toBeNull();
    });

    it("should have correct content after initialization", function () {
        expect($buttonElement.children(":visible").text()).toEqual("");
    });

    it ("shouldn't throw exception after first click on the button", function () {
        function clickButton() {
            $buttonElement.click();
        }
        expect(clickButton).not.toThrow();
    });

    it("should have correct content after clicking", function () {
        $buttonElement.click();
        expect($buttonElement.children(":visible").text()).toEqual(TotemUI.TwoStageButton.defaultConfiguration.confirmMessage);
    });

    it("should restore content to original state after configured timeout", function () {
        jasmine.Clock.useMock();

        // Checking content if it is normal
        expect($buttonElement.children(":visible").text()).toEqual("");

        // Clicking on the button to show the confirmation message
        $buttonElement.click();

        // Checking if content has confirm message
        expect($buttonElement.children(":visible").text()).toEqual(TotemUI.TwoStageButton.defaultConfiguration.confirmMessage);

        // Calling mouse leave event
        $buttonElement.mouseleave();

        // Making sure content is ok
        expect($buttonElement.children(":visible").text()).toEqual(TotemUI.TwoStageButton.defaultConfiguration.confirmMessage);

        // Calling timeout
        jasmine.Clock.tick(TotemUI.TwoStageButton.defaultConfiguration.clickTimeout + 1);

        // Checking if content went back to normal
        expect($buttonElement.children(":visible").text()).toEqual("");
    });
});
{'fraction_non_alphanumeric': 0.12908392056374118, 'fraction_numerical': 0.0009609224855861628, 'mean_word_length': 3.2547683923705724, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 3, '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': '5508022', 'n_tokens_mistral': 786, 'n_tokens_neox': 762, 'n_words': 167}