<commit_before>﻿const path = require('path');
const helpers = require('yeoman-test');
const assert = require('yeoman-assert');

describe('yo kk578:node-server MyNodeServerProject', () => {
	const dummies = [
		path.join(__dirname, '../generators/node'),
		[helpers.createDummyGenerator(), 'kk578:app']
	];

	before(() => {
		return helpers.run(path.join(__dirname, '../generators/node-server'))
			.withGenerators(dummies)
			.inDir(path.join(__dirname, './tmp/node-server'))
			.withArguments('MyNodeServerProject')
			.withPrompts({
				name: '<NAME>',
				email: '<EMAIL>',
				gitRemoteUrl: '<EMAIL>:KK578/MyNodeProject.git'
			})
			.toPromise();
	});

	it('should generate extra dependencies to package.json', () => {
		assert.fileContent('package.json', /"express"/);
		assert.fileContent('package.json', /"morgan"/);
		assert.fileContent('package.json', /"ejs"/);
		assert.fileContent('package.json', /"compression"/);
		assert.fileContent('package.json', /"browser-sync"/);
		assert.fileContent('package.json', /"grunt-express-server"/);
		assert.fileContent('package.json', /"grunt-contrib-watch"/);
		assert.fileContent('package.json', /"grunt-contrib-uglify"/);
	});

	it('should generate npm-shrinkwrap for uglifyjs', () => {
		assert.file('npm-shrinkwrap.json');
		assert.jsonFileContent('npm-shrinkwrap.json', {
			name: 'MyNodeServerProject',
			dependencies: {
				'uglify-js': {
					from: 'mishoo/UglifyJS2#harmony'
				}
			}
		});
	});

	it('should generate grunt configs for dependencies', () => {
		assert.file([
			'grunt/express.js',
			'grunt/watch.js',
			'grunt/uglify.js'
		]);
	});

	it('should generate server scripts for express', () => {
		assert.file([
			'server/development.js',
			'server/production.js',
			'server/server.js'
		]);
		assert.file([
			'server/configs/browser-sync.js',
			'server/configs/logs.js',
			'server/configs/router.js',
			'server/configs/setup.js'
		]);
		assert.file([
			'server/routes/static.js',
			'server/routes/dev-404.js'
		]);
	});

	it('should not copy files from development', () => {
		assert.noFile(['build/', 'node_modules/']);
	});
});
<commit_msg>Add test for .env file.<commit_after>﻿const path = require('path');
const helpers = require('yeoman-test');
const assert = require('yeoman-assert');

describe('yo kk578:node-server MyNodeServerProject', () => {
	const dummies = [
		path.join(__dirname, '../generators/node'),
		[helpers.createDummyGenerator(), 'kk578:app']
	];

	before(() => {
		return helpers.run(path.join(__dirname, '../generators/node-server'))
			.withGenerators(dummies)
			.inDir(path.join(__dirname, './tmp/node-server'))
			.withArguments('MyNodeServerProject')
			.withPrompts({
				name: '<NAME>',
				email: '<EMAIL>',
				gitRemoteUrl: '<EMAIL>:KK578/MyNodeProject.git'
			})
			.toPromise();
	});

	it('should generate extra dependencies to package.json', () => {
		assert.fileContent('package.json', /"express"/);
		assert.fileContent('package.json', /"morgan"/);
		assert.fileContent('package.json', /"ejs"/);
		assert.fileContent('package.json', /"compression"/);
		assert.fileContent('package.json', /"browser-sync"/);
		assert.fileContent('package.json', /"grunt-express-server"/);
		assert.fileContent('package.json', /"grunt-contrib-watch"/);
		assert.fileContent('package.json', /"grunt-contrib-uglify"/);
	});

	it('should generate npm-shrinkwrap for uglifyjs', () => {
		assert.file('npm-shrinkwrap.json');
		assert.jsonFileContent('npm-shrinkwrap.json', {
			name: 'MyNodeServerProject',
			dependencies: {
				'uglify-js': {
					from: 'mishoo/UglifyJS2#harmony'
				}
			}
		});
	});

	it('should generate grunt configs for dependencies', () => {
		assert.file([
			'grunt/express.js',
			'grunt/watch.js',
			'grunt/uglify.js'
		]);
	});

	it('should generate server scripts for express', () => {
		assert.file([
			'server/development.js',
			'server/production.js',
			'server/server.js'
		]);
		assert.file([
			'server/configs/browser-sync.js',
			'server/configs/logs.js',
			'server/configs/router.js',
			'server/configs/setup.js'
		]);
		assert.file([
			'server/routes/static.js',
			'server/routes/dev-404.js'
		]);
	});

	it('should generate a .env file', () => {
		assert.file(['.env']);
		assert.fileContent('.env', /NODE_ENV=development/);
		assert.fileContent('.env', /PORT=[0-9]*/);
		assert.fileContent('.env', /BROWSER_SYNC_PORT=[0-9]*/);
	});

	it('should not copy files from development', () => {
		assert.noFile(['build/', 'node_modules/']);
	});
});

{'fraction_non_alphanumeric': 0.20934371523915463, 'fraction_numerical': 0.006674082313681869, 'mean_word_length': 4.0460157126823795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '4117765', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1577, 'n_words': 226}