<commit_before>var expect = require('chai').expect,
    JsCop = require(".."),
    codeFromFunction = JsCop.Helper.codeFromFunction;

describe("AlwaysUseCurlyBracesCheck", function () {

    var cop;

    before(function () {
        cop = new JsCop();
    });

    it("should find missing curly braces for simple if", function () {

        var code = codeFromFunction(function () {
            if (1)
                console.log();
        });

        expect(cop.analyse(code).hasVialotions()).to.be.true;

    });

    it("should not has violation for simple if with curly braches", function () {

        var code = codeFromFunction(function () {
            if (1 === 2) {
                console.log();
            }
        });

        expect(cop.analyse(code).hasVialotions()).to.be.false;

    });

    it("should find missing curly braces for else", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else
                console.log("else");
        });

        expect(cop.analyse(code).hasVialotions()).to.be.true;

    });

    it("should handle if and else correctly", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else {
                console.log("else");
            }
        });

        expect(cop.analyse(code).hasVialotions()).to.be.false;

    });

    it("should find missing curly braces for while", function () {

        var code = codeFromFunction(function () {
            while (1)
                console.log();
        });
<commit_msg>extended tests for if else statement<commit_after>var expect = require('chai').expect,
    JsCop = require(".."),
    codeFromFunction = JsCop.Helper.codeFromFunction;

describe("AlwaysUseCurlyBracesCheck", function () {

    var cop;

    before(function () {
        cop = new JsCop();
    });

    it("should find missing curly braces for simple if", function () {

        var code = codeFromFunction(function () {
            if (1)
                console.log();
        });

        expect(cop.analyse(code).hasVialotions()).to.be.true;

    });

    it("should not has violation for simple if with curly braces", function () {

        var code = codeFromFunction(function () {
            if (1 === 2) {
                console.log();
            }
        });

        expect(cop.analyse(code).hasVialotions()).to.be.false;

    });

    it("should find missing curly braces for else", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else
                console.log("else");
        });

        expect(cop.analyse(code).hasVialotions()).to.be.true;

    });

    it("should handle if and else correctly", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else {
                console.log("else");
            }
        });

        expect(cop.analyse(code).hasVialotions()).to.be.false;

    });

    it("should find missing curly braces for if else", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else if (2)
                console.log("else");
        });

        expect(cop.analyse(code).hasVialotions()).to.be.true;

    });

    it("should handle if else correctly", function () {

        var code = codeFromFunction(function () {
            if (1) {
                console.log("if");
            } else if (2) {
                console.log("else");
            }
        });

        expect(cop.analyse(code).hasVialotions()).to.be.false;

    });

    it("should find missing curly braces for while", function () {

        var code = codeFromFunction(function () {
            while (1)
                console.log();
        });

{'fraction_non_alphanumeric': 0.14235234729934376, 'fraction_numerical': 0.004038364462392731, 'mean_word_length': 1.6977535738597687, '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': '2217602', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1061, 'n_words': 236}