<commit_before>var Q = require('q');
var path = require('path');

var repofs = require('../');
var GitHubLocal = require('../lib/drivers/github');

describe('GitHub Driver', function() {
    var fs = repofs(GitHubLocal, {
        repository: 'GitbookIO/gitbook'
    });

    describe('fs.stat', function() {
        it('should correctly return info for a file', function() {
            return fs.stat('README.md')
            .then(function(file) {
                file.type.should.equal('file');
                file.name.should.equal('README.md');
                file.path.should.equal('README.md');
            });
        });
    });

    describe('fs.read', function() {
        it('should correctly read from master', function() {
            return fs.read('README.md').should.be.fulfilled;
        });

        it('should fail for non-existant file', function() {
            return fs.read('error-repofs.js').should.be.rejected;
        });
    });

    describe('fs.readdir', function() {
        it('should correctly read the root directory', function() {
            return fs.readdir()
            .then(function(files) {
                files.should.have.property('README.md');

                files['README.md'].type.should.equal('file');
                files['README.md'].name.should.equal('README.md');
                files['README.md'].path.should.equal('README.md');
            });
        });
    });
});
<commit_msg>Improve tests for fs.readdir on github<commit_after>var Q = require('q');
var _ = require('lodash');
var path = require('path');

var repofs = require('../');
var GitHubLocal = require('../lib/drivers/github');

describe('GitHub Driver', function() {
    var fs = repofs(GitHubLocal, {
        repository: 'GitbookIO/gitbook'
    });

    describe('fs.stat', function() {
        it('should correctly return info for a file', function() {
            return fs.stat('README.md')
            .then(function(file) {
                file.type.should.equal('file');
                file.name.should.equal('README.md');
                file.path.should.equal('README.md');
            });
        });
    });

    describe('fs.read', function() {
        it('should correctly read from master', function() {
            return fs.read('README.md').should.be.fulfilled;
        });

        it('should fail for non-existant file', function() {
            return fs.read('error-repofs.js').should.be.rejected;
        });
    });

    describe('fs.readdir', function() {
        it('should correctly read the root directory', function() {
            return fs.readdir()
            .then(function(files) {
                files.should.have.property('README.md');

                files['README.md'].type.should.equal('file');
                files['README.md'].name.should.equal('README.md');
                files['README.md'].path.should.equal('README.md');
            });
        });

        it('should correctly read a sub-directory', function() {
            return fs.readdir('./lib')
            .then(function(files) {
                files.should.not.have.property('README.md');
                (_.size(files) > 0).should.equal(true);
            });
        });
    });
});

{'fraction_non_alphanumeric': 0.17307692307692307, 'fraction_numerical': 0.00031017369727047146, 'mean_word_length': 2.0027932960893855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2043512', 'n_tokens_mistral': 943, 'n_tokens_neox': 899, 'n_words': 159}