<commit_before>/* jshint expr:true */
'use strict';

/**
 * Test file for gulp-api-doc
 *
 * @author <NAME>      <<EMAIL>>
 * @since  28 Mar. 2015
 */

// module dependencies
var chai = require('chai'),
    sinon = require('sinon'),
    sinonChai = require('sinon-chai'),
    gulp = require('gulp'),
    concatStream = require('concat-stream'),
    apidocjs = require('apidoc'),
    apidoc = require('./');

var should = chai.should();
chai.use(sinonChai);

describe('gulp-api-doc', function() {

    it('Should call the createDoc method if files are passed in', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc())
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                apidocjs.createDoc.should.be.calledOnce;
                args.src.should.be.equal(__dirname + '/fixtures/');

                done();
            }));
    }));

    it('Should call the createDoc method with the correct source if a folder is passed in', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src('fixtures/')
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                apidocjs.createDoc.should.be.calledOnce;
                args.src.should.be.equal(__dirname + '/fixtures');

                done();
            }));
    }));

    it('Should call the createDoc method with the correct properties', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.includeFilters.should.be.eql(['doc.js', 'subfolder/subdoc.js']);
                should.not.exist(args.excludeFilters);
                should.not.exist(args.template);
                args.debug.should.be.false;
                args.silent.should.be.true;
                args.markdown.should.be.true;
                should.not.exist(args.marked);

                done();
            }));
    }));

    it('Should exclude files', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js', '!fixtures/subfolder/*.js'])
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.includeFilters.should.be.eql(['doc.js']);
                args.excludeFilters.should.be.eql(['subfolder/subdoc.js']);

                done();
            }));
    }));

    it('Should set the the debug property', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({debug: true, silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.debug.should.be.true;

                done();
            }));
    }));

    it('Should set the the markdown property', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({markdown: false, silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.markdown.should.be.false;

                done();
            }));
    }));

    it('Should throw an error if creating the documentation failed', sinon.test(function(done) {
        this.stub(apidocjs, 'createDoc').returns(undefined);

        var stream = gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({markdown: false, silent: true}));

        stream.on('error', function(err) {
            should.exist(err);

            done();<commit_msg>Test error if the base paths do not match.<commit_after>/* jshint expr:true */
'use strict';

/**
 * Test file for gulp-api-doc
 *
 * @author <NAME>      <<EMAIL>>
 * @since  28 Mar. 2015
 */

// module dependencies
var chai = require('chai'),
    sinon = require('sinon'),
    sinonChai = require('sinon-chai'),
    gulp = require('gulp'),
    concatStream = require('concat-stream'),
    apidocjs = require('apidoc'),
    apidoc = require('./');

var should = chai.should();
chai.use(sinonChai);

describe('gulp-api-doc', function() {

    it('Should call the createDoc method if files are passed in', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc())
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                apidocjs.createDoc.should.be.calledOnce;
                args.src.should.be.equal(__dirname + '/fixtures/');

                done();
            }));
    }));

    it('Should call the createDoc method with the correct source if a folder is passed in', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src('fixtures/')
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                apidocjs.createDoc.should.be.calledOnce;
                args.src.should.be.equal(__dirname + '/fixtures');

                done();
            }));
    }));

    it('Should call the createDoc method with the correct properties', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.includeFilters.should.be.eql(['doc.js', 'subfolder/subdoc.js']);
                should.not.exist(args.excludeFilters);
                should.not.exist(args.template);
                args.debug.should.be.false;
                args.silent.should.be.true;
                args.markdown.should.be.true;
                should.not.exist(args.marked);

                done();
            }));
    }));

    it('Should exclude files', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js', '!fixtures/subfolder/*.js'])
            .pipe(apidoc({silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.includeFilters.should.be.eql(['doc.js']);
                args.excludeFilters.should.be.eql(['subfolder/subdoc.js']);

                done();
            }));
    }));

    it('Should set the the debug property', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({debug: true, silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.debug.should.be.true;

                done();
            }));
    }));

    it('Should set the the markdown property', sinon.test(function(done) {
        this.spy(apidocjs, 'createDoc');

        gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({markdown: false, silent: true}))
            .pipe(concatStream(function() {
                var args = apidocjs.createDoc.args[0][0];

                args.markdown.should.be.false;

                done();
            }));
    }));

    it('Should throw an error if creating the documentation failed', sinon.test(function(done) {
        this.stub(apidocjs, 'createDoc').returns(undefined);

        var stream = gulp.src(['fixtures/**/*.js'])
            .pipe(apidoc({silent: true}));

        stream.on('error', function(err) {
            should.exist(err);

            done();
        });
    }));

    it('Should throw an error if the base paths are not the same', sinon.test(function(done) {
        this.stub(apidocjs, 'createDoc').returns(undefined);

        var stream = gulp.src(['fixtures/**/*.js', './**/*.js'])
            .pipe(apidoc({silent: true}));

        stream.on('error', function(err) {
            should.exist(err);

            done();
{'fraction_non_alphanumeric': 0.16519850368046338, 'fraction_numerical': 0.004344153493423434, 'mean_word_length': 1.9748743718592965, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5403238', 'n_tokens_mistral': 2608, 'n_tokens_neox': 2462, 'n_words': 428}