<commit_before>'use strict';

var formatter = require('../lib/formatter'),
    keyWords = require('../resources/key-words.json'),
    should = require('should');

describe('formatter', function() {
    it('exists', function() {
        formatter.should.be.ok;
    });

    it('is an object', function() {
        formatter.should.be.type('object');
    });

    describe('formatter.notes', function() {
        it('prevents more than 2 line breaks', function() {
            formatter.notes('hello\n\n\ndude').should.be.exactly('hello\n\ndude');
        });

        it('removes all prefacing & trailing whitespace', function() {
            formatter.notes('\nhello\n').should.be.exactly('hello');
            formatter.notes('\nhel\n\n\nlo\n').should.be.exactly('hel\n\nlo');
        });
    });

    describe('formatter.path', function() {
        var expected = '/aaaa/'

        it('removes duplicate trialing forward slashes', function() {
            formatter.path('/aaaa//').should.be.exactly('/aaaa/');
        });

        it('removes forward slashes occurring at various places', function() {
            formatter.path('/aa///aa//').should.be.exactly('/aa/aa/');
        });
    });

    // TODO: find valid regex checker
    describe('formatter.regex', function() {
        it('combines strings in an array into a regex or statement', function() {
            formatter.regex(['hello', 'dude']).should.match(RegExp('hello:|dude:'));
        });

        it('takes an infinite number of arguments', function() {
            var testStrings = ['dude'];
            for (var i = 0; i < 10; i++) {
                testStrings.push(i.toString());
                formatter.regex(testStrings).should.match(RegExp(testStrings.join(':|') + ':'));
            }
        });
    });

    describe('formatter.header', function() {
        var header = 'my-file.js';

        it('is a function', function() {
            formatter.header.should.be.type('function');
        });

        it('should format a header', function() {
            formatter.header(header).should.be.exactly(header + ':');
        });

        // TODO: move forward slash checking to formatter.path
        it('should remove any duplicate forward slashes', function() {
            var expected = 'directory/ello-dude/homie/bro.js:';

            formatter.header('directory//ello-dude/homie///bro.js').should.be.exactly(expected);
            formatter.header('directory//ello-dude/homie///bro.js').should.be.exactly(expected);
            formatter.header('directory//ello-dude////homie/bro.js').should.be.exactly(expected);
        });
    });

    describe('formatter.line', function() {
        var givenString, expectedString;<commit_msg>move path parsing logic spec all into formatter.path<commit_after>'use strict';

var formatter = require('../lib/formatter'),
    keyWords = require('../resources/key-words.json'),
    should = require('should');

describe('formatter', function() {
    it('exists', function() {
        formatter.should.be.ok;
    });

    it('is an object', function() {
        formatter.should.be.type('object');
    });

    describe('formatter.notes', function() {
        it('prevents more than 2 line breaks', function() {
            formatter.notes('hello\n\n\ndude').should.be.exactly('hello\n\ndude');
        });

        it('removes all prefacing & trailing whitespace', function() {
            formatter.notes('\nhello\n').should.be.exactly('hello');
            formatter.notes('\nhel\n\n\nlo\n').should.be.exactly('hel\n\nlo');
        });
    });

    describe('formatter.path', function() {
        it('removes duplicate trailing forward slashes', function() {
            formatter.path('/aaaa//').should.be.exactly('/aaaa/');
        });

        it('removes forward slashes occurring at various places', function() {
            formatter.path('/aa///aa//').should.be.exactly('/aa/aa/');
        });

        it('should remove any duplicate forward slashes from file path', function() {
            var expected = 'directory/ello-dude/homie/bro.js';

            formatter.path('directory//ello-dude/homie///bro.js').should.be.exactly(expected);
            formatter.path('directory//ello-dude/homie///bro.js').should.be.exactly(expected);
            formatter.path('directory//ello-dude////homie/bro.js').should.be.exactly(expected);
        });
    });

    // TODO: find valid regex checker
    describe('formatter.regex', function() {
        it('combines strings in an array into a regex or statement', function() {
            formatter.regex(['hello', 'dude']).should.match(RegExp('hello:|dude:'));
        });

        it('takes an infinite number of arguments', function() {
            var testStrings = ['dude'];
            for (var i = 0; i < 10; i++) {
                testStrings.push(i.toString());
                formatter.regex(testStrings).should.match(RegExp(testStrings.join(':|') + ':'));
            }
        });
    });

    describe('formatter.header', function() {
        var header = 'my-file.js';

        it('is a function', function() {
            formatter.header.should.be.type('function');
        });

        it('should add a trailing colon', function() {
            formatter.header(header).should.be.exactly(header + ':');
        });
    });

    describe('formatter.line', function() {
        var givenString, expectedString;
{'fraction_non_alphanumeric': 0.17796296296296296, 'fraction_numerical': 0.0014814814814814814, 'mean_word_length': 2.386206896551724, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5487923', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1487, 'n_words': 276}