<commit_before>describe("Buttton Tests", function() {
    beforeEach(function() {
        var result = yr.run('main', { username: 'bs' });
        $('.content').html(result);

        nb.init();

        this.button = nb.find('button');
    });

    afterEach(function() {
        delete this.button;
    });

    describe("Init", function() {
        it("Init", function() {
            expect(this.button).to.not.equal(null);
        });
    });
    describe("#setText()", function() {

        it("check text", function() {
            this.button.setText("Privet");
            expect($(this.button.node).find('.nb-button__text').html()).to.be.equal("Privet");
        });

        it("check event", function() {

            var flag = false;
            this.button.on('nb-button_text-setted', function() {
                flag = true;
            });

            this.button.setText("Privet");
            expect(flag).to.ok();
        });
    });

    describe("#getText()", function() {
        it("should return text", function() {
            expect(this.button.getText()).to.equal("Button");
        });
        it("should return new text after setText()", function() {
            this.button.setText("SetText");
            expect(this.button.getText()).to.equal("SetText");
        });
    });

    describe("#setUrl()", function() {
        it("check url", function() {
            this.button.setUrl("http://ya.ru");
            expect($(this.button.node).attr('href')).to.be.equal("http://ya.ru");
        });

        it("check event", function() {
            var flag = false;
            this.button.on('nb-button_url-setted', function() {
                flag = true;
            });

            this.button.setUrl("http://ya.ru");
            expect(flag).to.ok();
        });
    });

    describe("#getUrl()", function() {
        it("should return url", function() {
            expect(this.button.getUrl()).to.not.ok();
        });

        it("should return new url after setUrl()", function() {
            this.button.setUrl("http://yandex.ru");
            expect(this.button.getUrl()).to.be.equal("http://yandex.ru");
        });
    });

    describe("#disable()", function() {
        it("check state", function() {
            this.button.disable();
            expect(this.button.isEnabled()).to.not.ok();
        });

        it("check event", function() {
            var flag = true;

            this.button.on('nb-button_disabled', function() {
                flag = false;
            });

            this.button.disable();

            expect(flag).to.not.ok();
        });
    });

    describe("#enable()", function() {
        it("check state", function() {
            this.button.disable();
            this.button.enable();
            expect(this.button.isEnabled()).to.ok();
        });

        it("check event", function() {
            var flag = false;
            this.button.on('nb-button_enabled', function() {
                flag = true;
            });

            this.button.disable();
            this.button.enable();
            expect(flag).to.ok();
        });
    });

    describe("#destroy()", function() {
        var jquspy = sinon.spy($.fn, 'button');
        var nbspy = sinon.spy(nb, 'destroy');

        it("should call $.fn.button('destroy')", function() {
            this.button.destroy();
            sinon.assert.calledWith(jquspy, 'destroy');
        });

        it("should call nb.destroy('button')", function() {
            this.button.destroy();
            sinon.assert.calledWith(nbspy, 'button');
        });
    });


});<commit_msg>Move spy to beforeEach<commit_after>describe("Buttton Tests", function() {
    beforeEach(function() {
        var result = yr.run('main', { username: 'bs' });
        $('.content').html(result);

        nb.init();

        this.button = nb.find('button');
    });

    afterEach(function() {
        delete this.button;
    });

    describe("Init", function() {
        it("Init", function() {
            expect(this.button).to.not.equal(null);
        });
    });
    describe("#setText()", function() {

        it("check text", function() {
            this.button.setText("Privet");
            expect($(this.button.node).find('.nb-button__text').html()).to.be.equal("Privet");
        });

        it("check event", function() {

            var flag = false;
            this.button.on('nb-button_text-setted', function() {
                flag = true;
            });

            this.button.setText("Privet");
            expect(flag).to.ok();
        });
    });

    describe("#getText()", function() {
        it("should return text", function() {
            expect(this.button.getText()).to.equal("Button");
        });
        it("should return new text after setText()", function() {
            this.button.setText("SetText");
            expect(this.button.getText()).to.equal("SetText");
        });
    });

    describe("#setUrl()", function() {
        it("check url", function() {
            this.button.setUrl("http://ya.ru");
            expect($(this.button.node).attr('href')).to.be.equal("http://ya.ru");
        });

        it("check event", function() {
            var flag = false;
            this.button.on('nb-button_url-setted', function() {
                flag = true;
            });

            this.button.setUrl("http://ya.ru");
            expect(flag).to.ok();
        });
    });

    describe("#getUrl()", function() {
        it("should return url", function() {
            expect(this.button.getUrl()).to.not.ok();
        });

        it("should return new url after setUrl()", function() {
            this.button.setUrl("http://yandex.ru");
            expect(this.button.getUrl()).to.be.equal("http://yandex.ru");
        });
    });

    describe("#disable()", function() {
        it("check state", function() {
            this.button.disable();
            expect(this.button.isEnabled()).to.not.ok();
        });

        it("check event", function() {
            var flag = true;

            this.button.on('nb-button_disabled', function() {
                flag = false;
            });

            this.button.disable();

            expect(flag).to.not.ok();
        });
    });

    describe("#enable()", function() {
        it("check state", function() {
            this.button.disable();
            this.button.enable();
            expect(this.button.isEnabled()).to.ok();
        });

        it("check event", function() {
            var flag = false;
            this.button.on('nb-button_enabled', function() {
                flag = true;
            });

            this.button.disable();
            this.button.enable();
            expect(flag).to.ok();
        });
    });

    describe("#destroy()", function() {

        beforeEach(function() {
            sinon.spy($.fn, 'button');
            sinon.spy(nb, 'destroy');
        });

        afterEach(function() {
            $.fn.button.restore();
            nb.destroy.restore();
        });

        it("should call $.fn.button('destroy')", function() {
            this.button.destroy();
            expect($.fn.button.calledWithExactly('destroy')).to.be.equal(true);
        });

        it("should call nb.destroy('button')", function() {
            this.button.destroy();
            expect(nb.destroy.calledWithExactly('button')).to.be.equal(true);
        });
    });


});
{'fraction_non_alphanumeric': 0.19142091152815013, 'fraction_numerical': 0.0, 'mean_word_length': 1.7490788504053059, 'pattern_counts': {'":': 0, '<': 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': '4706178', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2047, 'n_words': 311}