From 39763525d7f1158836c7fa03b27b6b858c885a66 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Tue, 14 Feb 2017 18:15:27 -0800 Subject: [PATCH 1/2] add gulpfile and change assert to expect --- lab-noah/gulpfile.js | 23 +++++++++++++++++++++++ lab-noah/index.js | 6 ++++++ lab-noah/lib/greet.js | 12 ++++++++++++ lab-noah/package.json | 22 ++++++++++++++++++++++ lab-noah/test/greet-test.js | 24 ++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 lab-noah/gulpfile.js create mode 100644 lab-noah/index.js create mode 100644 lab-noah/lib/greet.js create mode 100644 lab-noah/package.json create mode 100644 lab-noah/test/greet-test.js 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..15cc3bc --- /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..6d304c0 --- /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'); + }); + }); +}); From f64eb2d4a6d7e75775f21067a643dd814ad0d7d2 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Wed, 15 Feb 2017 09:11:04 -0800 Subject: [PATCH 2/2] linting --- lab-noah/lib/greet.js | 2 +- lab-noah/test/greet-test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lab-noah/lib/greet.js b/lab-noah/lib/greet.js index 15cc3bc..e0015a3 100644 --- a/lab-noah/lib/greet.js +++ b/lab-noah/lib/greet.js @@ -9,4 +9,4 @@ exports.sayHey = function(name){ exports.sayBye = function() { return 'see ya later'; -} +}; diff --git a/lab-noah/test/greet-test.js b/lab-noah/test/greet-test.js index 6d304c0..b33f029 100644 --- a/lab-noah/test/greet-test.js +++ b/lab-noah/test/greet-test.js @@ -7,8 +7,8 @@ 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') + 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;