<commit_before>/*global describe, it, before */
'use strict';

var should = require('should'),
    es = require('event-stream'),
    gulp = require('gulp');

delete require.cache[require.resolve('..')];
var plumber = require('../');
var fixturesGlob = ['./test/fixtures/*'];

describe('stream', function () {

    it('should emit `end` after source emit `finish`', function (done) {
        gulp.src(fixturesGlob)
            .pipe(plumber({ errorHandler: done }))
            .on('finish', done)
            .on('error', done);
    });

    it('should passThrough all incoming files', function (done) {
        gulp.src(fixturesGlob)
            .pipe(plumber({ errorHandler: done }))
            .pipe(es.writeArray(function (err, array) {
                array.should.eql(this.expected);
                done();
            }.bind(this)))
            .on('error', done);
    });

    it('should passThrough all incoming files with on(`data`) handler attached', function (done) {
        gulp.src(fixturesGlob)<commit_msg>Added test for piping through es.readArray<commit_after>/*global describe, it, before */
'use strict';

var should = require('should'),
    es = require('event-stream'),
    gulp = require('gulp');

delete require.cache[require.resolve('..')];
var plumber = require('../');
var fixturesGlob = ['./test/fixtures/*'];

describe('stream', function () {

    it('should work with es.readarray', function (done) {
        var expected = ['1\n', '2\n', '3\n', '4\n', '5\n'];

        es.readArray([1, 2, 3, 4, 5])
            .pipe(plumber())
            .pipe(es.stringify())
            .pipe(es.writeArray(function (error, array) {
                array.should.eql(expected);
                done();
            }));
    });

    it('should emit `end` after source emit `finish`', function (done) {
        gulp.src(fixturesGlob)
            .pipe(plumber())
            .on('finish', done)
            .on('error', done);
    });

    it('should passThrough all incoming files', function (done) {
        gulp.src(fixturesGlob)
            .pipe(plumber({ errorHandler: done }))
            .pipe(es.writeArray(function (err, array) {
                array.should.eql(this.expected);
                done();
            }.bind(this)))
            .on('error', done);
    });

    it('should passThrough all incoming files with on(`data`) handler attached', function (done) {
        gulp.src(fixturesGlob)
{'fraction_non_alphanumeric': 0.17140502678203542, 'fraction_numerical': 0.004120313143798929, 'mean_word_length': 2.326027397260274, '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': '5589138', 'n_tokens_mistral': 739, 'n_tokens_neox': 712, 'n_words': 169}