From ac27f64793a360475eb0c6eebf63b27820317b98 Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Mon, 12 Sep 2016 16:53:06 -0700 Subject: [PATCH 1/7] init done --- lab-logan/.eslintrc | 24 ++++++++++++++++++++++++ lab-logan/package.json | 11 +++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lab-logan/.eslintrc create mode 100644 lab-logan/package.json diff --git a/lab-logan/.eslintrc b/lab-logan/.eslintrc new file mode 100644 index 0000000..86e3575 --- /dev/null +++ b/lab-logan/.eslintrc @@ -0,0 +1,24 @@ +{ + "rules": { + "comma-dangle": ["error", "always-multiline"], + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "globals": { + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/lab-logan/package.json b/lab-logan/package.json new file mode 100644 index 0000000..3be694b --- /dev/null +++ b/lab-logan/package.json @@ -0,0 +1,11 @@ +{ + "name": "lab-logan", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} From 6b81ff4e734ef46fc5f114151c59b0a6bd43facb Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 09:09:38 -0700 Subject: [PATCH 2/7] set up functionality and test --- lab-logan/test/greet-test.js | 13 +++++++++++++ lab-logan/test/greet.js | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 lab-logan/test/greet-test.js create mode 100644 lab-logan/test/greet.js diff --git a/lab-logan/test/greet-test.js b/lab-logan/test/greet-test.js new file mode 100644 index 0000000..5176e1d --- /dev/null +++ b/lab-logan/test/greet-test.js @@ -0,0 +1,13 @@ +'use strict'; + +const greetings = require('../test/greet.js'); +const assert = require('assert'); + +describe ('testing for module greet', function(){ + describe ('testing #hello', function(){ + it('should return hello', function(){ + let result = greetings.sayHello(); + assert.ok(true === false, 'Complete failure!'); + }); + }); +}); diff --git a/lab-logan/test/greet.js b/lab-logan/test/greet.js new file mode 100644 index 0000000..abe5954 --- /dev/null +++ b/lab-logan/test/greet.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = {}; + +module.exports = function greet(name){ + return 'Hi there ' + name; +}; From 5830b99165f69c487fdf80733a5bd718e14d8136 Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 09:39:23 -0700 Subject: [PATCH 3/7] worked on testing. Still failing --- lab-logan/test/greet-test.js | 16 +++++++++------- lab-logan/test/greet.js | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lab-logan/test/greet-test.js b/lab-logan/test/greet-test.js index 5176e1d..780f1e7 100644 --- a/lab-logan/test/greet-test.js +++ b/lab-logan/test/greet-test.js @@ -1,13 +1,15 @@ 'use strict'; -const greetings = require('../test/greet.js'); +const greet = require('../test/greet.js'); const assert = require('assert'); -describe ('testing for module greet', function(){ - describe ('testing #hello', function(){ - it('should return hello', function(){ - let result = greetings.sayHello(); - assert.ok(true === false, 'Complete failure!'); - }); +describe ('testing greet module', function(){ + it('should return hello world', function(){ + assert.equal(greet(), 'hello world'); + }); + it('should throw missing name error', function(){ + assert.throws(function(){ + greet(); + }, 'error thrown'); }); }); diff --git a/lab-logan/test/greet.js b/lab-logan/test/greet.js index abe5954..d549e72 100644 --- a/lab-logan/test/greet.js +++ b/lab-logan/test/greet.js @@ -1,7 +1,6 @@ 'use strict'; -module.exports = {}; - module.exports = function greet(name){ - return 'Hi there ' + name; + if (!name) throw new Error('expected a name'); + return 'hello ' + name; }; From f27632ffd30856a8912a4d76201649f533cef8c2 Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 13:11:05 -0700 Subject: [PATCH 4/7] added and implemented gulp to work and watch files --- lab-logan/gulpfile.js | 21 +++++++++++++++++++++ lab-logan/package.json | 6 +++++- lab-logan/test/greet-test.js | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 lab-logan/gulpfile.js diff --git a/lab-logan/gulpfile.js b/lab-logan/gulpfile.js new file mode 100644 index 0000000..8560944 --- /dev/null +++ b/lab-logan/gulpfile.js @@ -0,0 +1,21 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require('gulp-mocha'); + +gulp.task('test', function(){ + gulp.src('./test/*-test.js', {read: false}) + .pipe(mocha({reporter: 'nyan'})); +}); + +gulp.task('lint',function(){ + return gulp.src(['**/*.js','!node_modules/**']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('watch:lint', function(){ + gulp.watch(['**/*.js', '!node_modules/**'], ['lint']); +}); diff --git a/lab-logan/package.json b/lab-logan/package.json index 3be694b..c6c04ab 100644 --- a/lab-logan/package.json +++ b/lab-logan/package.json @@ -7,5 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "gulp-mocha": "^3.0.1", + "mocha": "^3.0.2" + } } diff --git a/lab-logan/test/greet-test.js b/lab-logan/test/greet-test.js index 780f1e7..9188f48 100644 --- a/lab-logan/test/greet-test.js +++ b/lab-logan/test/greet-test.js @@ -5,7 +5,7 @@ const assert = require('assert'); describe ('testing greet module', function(){ it('should return hello world', function(){ - assert.equal(greet(), 'hello world'); + assert.equal(greet('world'), 'hello world'); }); it('should throw missing name error', function(){ assert.throws(function(){ From e7b26d702eb30b58c0ca7ccdb2ff1a4f25c5e25c Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 13:21:52 -0700 Subject: [PATCH 5/7] added gitignore, updated gulpfile --- lab-logan/.gitignore | 86 +++++++++++++++++++++++++++++++++++++++++++ lab-logan/gulpfile.js | 4 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 lab-logan/.gitignore diff --git a/lab-logan/.gitignore b/lab-logan/.gitignore new file mode 100644 index 0000000..a3cc5ef --- /dev/null +++ b/lab-logan/.gitignore @@ -0,0 +1,86 @@ +# Created by https://www.gitignore.io/api/osx,linux,node + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history diff --git a/lab-logan/gulpfile.js b/lab-logan/gulpfile.js index 8560944..6114c99 100644 --- a/lab-logan/gulpfile.js +++ b/lab-logan/gulpfile.js @@ -17,5 +17,7 @@ gulp.task('lint',function(){ }); gulp.task('watch:lint', function(){ - gulp.watch(['**/*.js', '!node_modules/**'], ['lint']); + gulp.watch(['**/*.js', '!node_modules/**'], ['test', 'lint']); }); + +gulp.task('default', ['dev']); From 4392e12adbc29b9c78b7d3b4a2e038adc2e5ffb8 Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 16:07:50 -0700 Subject: [PATCH 6/7] added watch:lint to the default gulp task --- lab-logan/gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-logan/gulpfile.js b/lab-logan/gulpfile.js index 6114c99..fdfc78a 100644 --- a/lab-logan/gulpfile.js +++ b/lab-logan/gulpfile.js @@ -20,4 +20,4 @@ gulp.task('watch:lint', function(){ gulp.watch(['**/*.js', '!node_modules/**'], ['test', 'lint']); }); -gulp.task('default', ['dev']); +gulp.task('default', ['watch:lint', 'dev']); From 039064238a43a416489bc367b7ac2f0b314eda2c Mon Sep 17 00:00:00 2001 From: Logan Rogers Date: Tue, 13 Sep 2016 16:09:27 -0700 Subject: [PATCH 7/7] got rid of unneccessary bit of code --- lab-logan/gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-logan/gulpfile.js b/lab-logan/gulpfile.js index fdfc78a..4afbee6 100644 --- a/lab-logan/gulpfile.js +++ b/lab-logan/gulpfile.js @@ -20,4 +20,4 @@ gulp.task('watch:lint', function(){ gulp.watch(['**/*.js', '!node_modules/**'], ['test', 'lint']); }); -gulp.task('default', ['watch:lint', 'dev']); +gulp.task('default', ['watch:lint']);