diff --git a/lab-noah/gulpfile.js b/lab-noah/gulpfile.js new file mode 100644 index 0000000..75631ef --- /dev/null +++ b/lab-noah/gulpfile.js @@ -0,0 +1,23 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require('gulp-mocha'); + +gulp.task('lint', function(){ + return gulp.src(['**/*.js', '!node_modules']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('test', function(){ + gulp.src('./test/*-test.js', {read: false}) + .pipe(mocha({reporter: 'nyan'})); +}); + +gulp.task('dev', function(){ + gulp.watch(['**/*.js', '!node_modules/**'], ['lint', 'test']); +}); + +gulp.task('default', ['dev']); diff --git a/lab-noah/index.js b/lab-noah/index.js new file mode 100644 index 0000000..6251f2a --- /dev/null +++ b/lab-noah/index.js @@ -0,0 +1,6 @@ +'use strict'; + +const greet = require('./lib/greet.js'); + +greet.sayHey(); +greet.sayBye(); diff --git a/lab-noah/lib/greet.js b/lab-noah/lib/greet.js new file mode 100644 index 0000000..e0015a3 --- /dev/null +++ b/lab-noah/lib/greet.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = exports = {}; + +exports.sayHey = function(name){ + if(arguments.length === 0) throw new Error('no name entered'); + return `hey ${name}`; +}; + +exports.sayBye = function() { + return 'see ya later'; +}; diff --git a/lab-noah/package.json b/lab-noah/package.json new file mode 100644 index 0000000..27e886d --- /dev/null +++ b/lab-noah/package.json @@ -0,0 +1,22 @@ +{ + "name": "demo-1", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "chai": "^3.5.0", + "gulp": "^3.9.1", + "gulp-eslint": "^3.0.1", + "gulp-mocha": "^3.0.1", + "mocha": "^3.2.0" + } +} diff --git a/lab-noah/test/greet-test.js b/lab-noah/test/greet-test.js new file mode 100644 index 0000000..b33f029 --- /dev/null +++ b/lab-noah/test/greet-test.js @@ -0,0 +1,24 @@ +'use strict'; + +const greet = require('../lib/greet.js'); +const expect = require('chai').expect; + +describe('Greet Module', function(){ + describe('#sayHey',function(){ + it('should return hey noah',function(){ + var result = greet.sayHey('noah'); + expect(greet).to.have.property('sayHey'); + expect(result).to.equal('hey noah'); + }); + it('should have a missing name error message', function(){ + var result = greet.sayHey; + expect(result).to.throw(Error); + }); + }); + describe('#sayBye',function(){ + it('should return see ya later', function(){ + var result = greet.sayBye(); + expect(result).to.equal('see ya later'); + }); + }); +});