<commit_before>/* global describe, it, before, afterEach */

'use strict';

var _       = require( 'lodash' ),
	should  = require( 'should' ),
	sinon   = require( 'sinon' ),
	gutil   = require( 'gulp-util' ),
	request = require( 'supertest' ),
	app     = require( '../' );

var URL  = 'http://localhost:1337',
	stub = null;


describe( 'gulp-develop-server', function() {

	before( function() {
		stub = sinon.stub( gutil, 'log' );
	});


	afterEach( function( done ) {
		var end = function() {
			stub.reset();
			done();
		};

		if( app.child && app.child.connected ) {
			return app.reset( end );
		}

		end();
	});


	it( 'should listen the server', function( done ) {
		var opt = {
			path: 'test/apps/app-no-message'
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the server by checking message', function( done ) {
		var opt = {
			path: 'test/apps/app'
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the server by only checking message', function( done ) {
		var opt = {
			path: 'test/apps/app',
			delay: 0
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the express server', function( done ) {
		var opt = {
			path: 'test/apps/app-express',
			delay: 1200
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should set `options.execArgv`', function( done ) {
		var opt = {
			path: 'test/apps/app',
			execArgv: [ '--harmony' ]
		};

		app.listen( opt, function() {
			should( app.options.execArgv ).eql( opt.execArgv );
			done();
		});
	});


	it( 'should set `options.env`', function( done ) {
		var opt = {
			path: 'test/apps/app',
			env: { NODE_ENV: 'production', PORT: 1338 }
		};

		app.listen( opt, function() {
			should( app.options.env.NODE_ENV ).eql( opt.env.NODE_ENV );
			should( app.options.env.PORT ).eql( opt.env.PORT );
			done();
		});
	});


	it( 'should include current environmental variables by default', function( done ) {
		var opt = {
			path: 'test/apps/app'
		};
		var envExtended = _.extend( app.defaultOptions.env, process.env );

		app.listen( opt, function() {
			should( app.options.env ).eql( envExtended );
			done();
		});
	});


	it( 'should listen the server with `options.delay`', function( done ) {
		var opt = {
			path: 'test/apps/app-no-message',
			delay: 50
		};
		var now = Date.now();

		app.listen( opt, function() {
			var delay = Date.now() - now;

			should( delay ).within( 50, 80 );
			should( app.options.delay ).eql( opt.delay );
			done();<commit_msg>Fixed test variables extended environment values<commit_after>/* global describe, it, before, afterEach */

'use strict';

var _       = require( 'lodash' ),
	should  = require( 'should' ),
	sinon   = require( 'sinon' ),
	gutil   = require( 'gulp-util' ),
	request = require( 'supertest' ),
	app     = require( '../' );

var URL  = 'http://localhost:1337',
	stub = null;


describe( 'gulp-develop-server', function() {

	before( function() {
		stub = sinon.stub( gutil, 'log' );
	});


	afterEach( function( done ) {
		var end = function() {
			stub.reset();
			done();
		};

		if( app.child && app.child.connected ) {
			return app.reset( end );
		}

		end();
	});


	it( 'should listen the server', function( done ) {
		var opt = {
			path: 'test/apps/app-no-message'
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the server by checking message', function( done ) {
		var opt = {
			path: 'test/apps/app'
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the server by only checking message', function( done ) {
		var opt = {
			path: 'test/apps/app',
			delay: 0
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should listen the express server', function( done ) {
		var opt = {
			path: 'test/apps/app-express',
			delay: 1200
		};

		app.listen( opt, function( error ) {
			should.not.exist( error );
			should( app.child.connected ).be.true;
			should( gutil.log.lastCall.args[ 0 ] ).match( /server listening/ );
			request( URL ).get( '/' ).expect( 200 ).end( done );
		});
	});


	it( 'should set `options.execArgv`', function( done ) {
		var opt = {
			path: 'test/apps/app',
			execArgv: [ '--harmony' ]
		};

		app.listen( opt, function() {
			should( app.options.execArgv ).eql( opt.execArgv );
			done();
		});
	});


	it( 'should set `options.env`', function( done ) {
		var opt = {
			path: 'test/apps/app',
			env: { NODE_ENV: 'production', PORT: 1338 }
		};

		app.listen( opt, function() {
			should( app.options.env.NODE_ENV ).eql( opt.env.NODE_ENV );
			should( app.options.env.PORT ).eql( opt.env.PORT );
			done();
		});
	});


	it( 'should include current environmental variables by default', function( done ) {
		var opt = {
			path: 'test/apps/app'
		};
		var envExtended = _.extend( { NODE_ENV: 'development' }, process.env );

		app.listen( opt, function() {
			should( app.options.env ).eql( envExtended );
			done();
		});
	});


	it( 'should listen the server with `options.delay`', function( done ) {
		var opt = {
			path: 'test/apps/app-no-message',
			delay: 50
		};
		var now = Date.now();

		app.listen( opt, function() {
			var delay = Date.now() - now;

			should( delay ).within( 50, 80 );
			should( app.options.delay ).eql( opt.delay );
			done();
{'fraction_non_alphanumeric': 0.1875187069739599, 'fraction_numerical': 0.010475905417539658, 'mean_word_length': 2.834193918531268, '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': '1490042', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2336, 'n_words': 619}