<commit_before>'use strict';

var assert = require('assert');
var gutil = require('gulp-util');
var jsxcs = require('./');

describe('gulp-jsxcs test suite:', function() {

    it('check JS files', function (cb) {
        var stream = jsxcs();
        var success = false;

        stream.on('data', function() {});

        stream.on('end', function() {
            if (!success) {
                assert(false, 'Failed to raise expected style errors');
            }
            cb();
        });

        stream.on('error', function (err) {
            if (/Illegal space before/.test(err)
                && /Multiple var declaration/.test(err)
                && /Invalid quote mark found/.test(err)) {
                success = true;
            }
        });

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture.js',
            contents: new Buffer('var x = 1,y = 2;')
        }));

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture2.js',
            contents: new Buffer('var x = { a: 1 };')
        }));

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture2.js',
            contents: new Buffer('var x = "foo";')
        }));

        stream.end();
    });

    it('check JS files using a preset', function (cb) {
        var stream = jsxcs({preset: 'google'});
        var success = false;

        stream.on('data', function() {});

        stream.on('end', function() {
            if (!success) {
                assert(false, 'Failed to raise expected style errors');
            }
            cb();
        });

        stream.on('error', function (err) {
            if (/Missing line feed at file end/.test(err)) {<commit_msg>Fix for using same filename in stream<commit_after>'use strict';

var assert = require('assert');
var gutil = require('gulp-util');
var jsxcs = require('./');

describe('gulp-jsxcs test suite:', function() {

    it('check JS files', function (cb) {
        var stream = jsxcs();
        var success = false;

        stream.on('data', function() {});

        stream.on('end', function() {
            if (!success) {
                assert(false, 'Failed to raise expected style errors');
            }
            cb();
        });

        stream.on('error', function (err) {
            if (/Illegal space before/.test(err)
                && /Multiple var declaration/.test(err)
                && /Invalid quote mark found/.test(err)) {
                success = true;
            }
        });

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture.js',
            contents: new Buffer('var x = 1,y = 2;')
        }));

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture2.js',
            contents: new Buffer('var x = { a: 1 };')
        }));

        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture3.js',
            contents: new Buffer('var x = "foo";')
        }));

        stream.end();
    });

    it('check JS files using a preset', function (cb) {
        var stream = jsxcs({preset: 'google'});
        var success = false;

        stream.on('data', function() {});

        stream.on('end', function() {
            if (!success) {
                assert(false, 'Failed to raise expected style errors');
            }
            cb();
        });

        stream.on('error', function (err) {
            if (/Missing line feed at file end/.test(err)) {
{'fraction_non_alphanumeric': 0.15350877192982457, 'fraction_numerical': 0.0027412280701754384, 'mean_word_length': 1.623292595255212, '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': '6994691', 'n_tokens_mistral': 1035, 'n_tokens_neox': 994, 'n_words': 274}