<commit_before>var rewire = require('rewire'),
    expect = require('chai').expect,
    utils = rewire('../../lib/utils'),
    dockerCerts = require('../spec_helper').dockerCerts;

var fsStub = {
    readFileSync: function(path) { return path; }
};

utils.__set__('fs', fsStub);

describe('Utils', function() {
    describe('.formatImage()', function() {
        context('when a repository is specified', function() {
            it('formats image name with repository prefix', function() {
                var formated = utils.formatImage('grounds', 'ruby');

                expect(formated).to.equal('grounds/exec-ruby');
            });
        });

        context('when no repository is specified', function() {
            it('formats image name without repository prefix', function() {
                expect(utils.formatImage('', 'ruby')).to.equal('exec-ruby');
            });
        });

        context('when no language is specified', function() {
            it('returns an empty string', function() {
                expect(utils.formatImage('grounds', '')).to.equal('');
            });
        });
    });

    describe('.formatCmd()', function() {
        it('returns an escaped string', function() {
            var code     = 'puts "Hello world\\n\\r\\t"\r\n\t',
                expected = 'puts "Hello world\\\\n\\\\r\\\\t"\\r\\n\\t';

            expect(utils.formatCmd(code)).to.equal(expected);
        });<commit_msg>fix bad style in utils tests<commit_after>var rewire = require('rewire'),
    expect = require('chai').expect,
    utils = rewire('../../lib/utils'),
    dockerCerts = require('../spec_helper').dockerCerts;

utils.__set__('fs', {
    readFileSync: function(path) { return path; }
});

describe('Utils', function() {
    describe('.formatImage()', function() {
        context('when a repository is specified', function() {
            it('formats image name with repository prefix', function() {
                var formated = utils.formatImage('grounds', 'ruby');

                expect(formated).to.equal('grounds/exec-ruby');
            });
        });

        context('when no repository is specified', function() {
            it('formats image name without repository prefix', function() {
                expect(utils.formatImage('', 'ruby')).to.equal('exec-ruby');
            });
        });

        context('when no language is specified', function() {
            it('returns an empty string', function() {
                expect(utils.formatImage('grounds', '')).to.equal('');
            });
        });
    });

    describe('.formatCmd()', function() {
        it('returns an escaped string', function() {
            var code     = 'puts "Hello world\\n\\r\\t"\r\n\t',
                expected = 'puts "Hello world\\\\n\\\\r\\\\t"\\r\\n\\t';

            expect(utils.formatCmd(code)).to.equal(expected);
        });
{'fraction_non_alphanumeric': 0.1806182702327197, 'fraction_numerical': 0.0, 'mean_word_length': 2.1964483906770256, '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': '3347039', 'n_tokens_mistral': 801, 'n_tokens_neox': 759, 'n_words': 170}