<commit_before>var Hook = require('../');
var Path = require('path');

var Lab = require('lab');

var lab = exports.lab = Lab.script();
var expect = Lab.expect;
var describe = lab.experiment;
var it = lab.test;

var internals = {};


internals.getMatcher = function () {

    var sep = new RegExp(Path.sep, 'g');
    var path = Path.join.apply(null, arguments).replace(sep, '\\' + Path.sep);
    return new RegExp(path + '$');
};


describe('exports', function () {

    it('can find a git root', function (done) {

        var root = Hook.findGitRoot(__dirname);
        expect(root).to.be.a('string');
        expect(root).to.match(internals.getMatcher(__dirname));
        done();
    });

    it('can find a git root from higher up', function (done) {

        var root = Hook.findGitRoot(Path.join(__dirname, 'projects'));
        expect(root).to.be.a('string');
        expect(root).to.match(internals.getMatcher(__dirname));
        done();
    });

    it('can find a project root', function (done) {

        var root = Hook.findProjectRoot(__dirname);
        expect(root).to.be.a('string');
        expect(root).to.match(internals.getMatcher(__dirname));
        done();
    });

    it('can find a project root from higher up', function (done) {

        var root = Hook.findProjectRoot(Path.join(__dirname, 'projects', 'project6', 'node_modules', 'nope'));
        expect(root).to.be.a('string');
        expect(root).to.match(internals.getMatcher(__dirname, 'projects', 'project6'));
        done();
    });

    it('can find projects', function (done) {

        var projects = Hook.findProjects(Path.join(__dirname, 'projects'));
        expect(projects).to.be.an('array');
        expect(projects).to.have.length(4);
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project1'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project2'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project3', 'api'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project4', 'even', 'deeper', 'thing'));
        done();
    });
});<commit_msg>simplify tests<commit_after>var Hook = require('../');
var Path = require('path');

var Lab = require('lab');

var lab = exports.lab = Lab.script();
var expect = Lab.expect;
var describe = lab.experiment;
var it = lab.test;

var internals = {};


internals.getMatcher = function () {

    var sep = new RegExp(Path.sep, 'g');
    var path = Path.join.apply(null, arguments).replace(sep, '\\' + Path.sep);
    return new RegExp(path + '$');
};


describe('exports', function () {

    it('can find a git root', function (done) {

        var root = Hook.findGitRoot(__dirname);
        expect(root).to.be.a('string');
        expect(root).to.equal(__dirname);
        done();
    });

    it('can find a git root from higher up', function (done) {

        var root = Hook.findGitRoot(Path.join(__dirname, 'projects'));
        expect(root).to.be.a('string');
        expect(root).to.equal(__dirname);
        done();
    });

    it('can find a project root', function (done) {

        var root = Hook.findProjectRoot(__dirname);
        expect(root).to.be.a('string');
        expect(root).to.equal(__dirname);
        done();
    });

    it('can find a project root from higher up', function (done) {

        var root = Hook.findProjectRoot(Path.join(__dirname, 'projects', 'project6', 'node_modules', 'nope'));
        expect(root).to.be.a('string');
        expect(root).to.equal(Path.join(__dirname, 'projects', 'project6'));
        done();
    });

    it('can find projects', function (done) {

        var projects = Hook.findProjects(Path.join(__dirname, 'projects'));
        expect(projects).to.be.an('array');
        expect(projects).to.have.length(4);
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project1'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project2'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project3', 'api'));
        expect(projects).to.contain(Path.join(__dirname, 'projects', 'project4', 'even', 'deeper', 'thing'));
        done();
    });
});
{'fraction_non_alphanumeric': 0.18348405521180391, 'fraction_numerical': 0.0033317467872441696, 'mean_word_length': 3.2156469408224675, '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': '2793859', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1262, 'n_words': 269}