<commit_before>#!/usr/bin/env node
var consoleMock = require('console-mock'),
    console = consoleMock.create(),
    utils = require('./utils')(console),
    childProcess = require('child_process'),
    shell = require('shelljs');

require('colors');


consoleMock.enabled(false);//disable console.log prints


describe('utils.js', function () {
    'use strict';

    function gitInitInTempFolder () {
        shell.rm('-rf', 'tmp');
        shell.config.silent = true;
        shell.mkdir('tmp');
        shell.cd('tmp');
        shell.exec('git init');
    }

    function finishTemp () {
        shell.cd('../');
        shell.rm('-rf', 'tmp');
    }

    describe('should have defined', function () {
        it('checkGitRepoExistence', function () {
            expect(utils.checkGitRepoExistence).toBeDefined();
        });
        it('showError', function () {
            expect(utils.showError).toBeDefined();
        });
    });
    describe('behavior', function () {
        describe('showError', function () {
            beforeEach( function () {
                // consoleMock.enabled(true);
                // consoleMock.historyClear();
                spyOn(console, 'log');
                spyOn(childProcess, 'exec');
            });

            it('should return a undefined', function () {
                expect(utils.showError()).toBeUndefined();
            });
            it('should call console.log', function () {
                utils.showError();
                expect(console.log).toHaveBeenCalled();
            });
            it('should call console.log with error without params', function () {
                utils.showError();
                expect(console.log).toHaveBeenCalledWith('error'.magenta);
            });
            it('should call console.log with the param passed', function () {
                utils.showError('hola');
                expect(console.log).toHaveBeenCalledWith('hola'.magenta);
            });
        });
        describe('checkGitRepoExistence', function () {
            beforeEach( function() {
                spyOn(childProcess, 'exec').andCallThrough();
            });
            it('should return a promise obj', function () {
                expect(typeof utils.checkGitRepoExistence()).toBe('object');
            });
            it('should have a then method', function () {
                expect(utils.checkGitRepoExistence().then).toBeDefined();
            });
            it('should have a catch method', function () {
                expect(utils.checkGitRepoExistence().catch).toBeDefined();
            });
            it('should run chilProcess exec command', function () {
                utils.checkGitRepoExistence();
                expect(childProcess.exec).toHaveBeenCalled();
            });

            it('should execute a git branch command', function () {
                utils.checkGitRepoExistence();
                expect(childProcess.exec).toHaveBeenCalledWith('git branch');
            });

            describe('with a real git repo', function () {
                it('should resolve the promise with a git repo init', function (done) {
                    gitInitInTempFolder();
                    utils.checkGitRepoExistence().then(function () {
                        expect('').toBe('');
                        finishTemp();
                        done();
                    });<commit_msg>[DEL] utils.spec: remove unnecessary expect<commit_after>#!/usr/bin/env node
var consoleMock = require('console-mock'),
    console = consoleMock.create(),
    utils = require('./utils')(console),
    childProcess = require('child_process'),
    shell = require('shelljs');

require('colors');


consoleMock.enabled(false);//disable console.log prints


describe('utils.js', function () {
    'use strict';

    function gitInitInTempFolder () {
        shell.rm('-rf', 'tmp');
        shell.config.silent = true;
        shell.mkdir('tmp');
        shell.cd('tmp');
        shell.exec('git init');
    }

    function finishTemp () {
        shell.cd('../');
        shell.rm('-rf', 'tmp');
    }

    describe('should have defined', function () {
        it('checkGitRepoExistence', function () {
            expect(utils.checkGitRepoExistence).toBeDefined();
        });
        it('showError', function () {
            expect(utils.showError).toBeDefined();
        });
    });
    describe('behavior', function () {
        describe('showError', function () {
            beforeEach( function () {
                // consoleMock.enabled(true);
                // consoleMock.historyClear();
                spyOn(console, 'log');
                spyOn(childProcess, 'exec');
            });

            it('should return a undefined', function () {
                expect(utils.showError()).toBeUndefined();
            });
            it('should call console.log', function () {
                utils.showError();
                expect(console.log).toHaveBeenCalled();
            });
            it('should call console.log with error without params', function () {
                utils.showError();
                expect(console.log).toHaveBeenCalledWith('error'.magenta);
            });
            it('should call console.log with the param passed', function () {
                utils.showError('hola');
                expect(console.log).toHaveBeenCalledWith('hola'.magenta);
            });
        });
        describe('checkGitRepoExistence', function () {
            beforeEach( function() {
                spyOn(childProcess, 'exec').andCallThrough();
            });
            it('should return a promise obj', function () {
                expect(typeof utils.checkGitRepoExistence()).toBe('object');
            });
            it('should have a then method', function () {
                expect(utils.checkGitRepoExistence().then).toBeDefined();
            });
            it('should have a catch method', function () {
                expect(utils.checkGitRepoExistence().catch).toBeDefined();
            });
            it('should run chilProcess exec command', function () {
                utils.checkGitRepoExistence();
                expect(childProcess.exec).toHaveBeenCalled();
            });

            it('should execute a git branch command', function () {
                utils.checkGitRepoExistence();
                expect(childProcess.exec).toHaveBeenCalledWith('git branch');
            });

            describe('with a real git repo', function () {
                it('should resolve the promise with a git repo init', function (done) {
                    gitInitInTempFolder();
                    utils.checkGitRepoExistence().then(function () {
                        finishTemp();
                        done();
                    });
{'fraction_non_alphanumeric': 0.1402376411911398, 'fraction_numerical': 0.0, 'mean_word_length': 1.8196856906534327, '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': '4465515', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1647, 'n_words': 319}